A colleague wrote ~/sched-lab/backup.sh — a backup of the data directory into the archive directory — and put it on the nightly lab-backup timer. By hand, the script works, yet in the morning there are no new archives. Run the backup by hand, then as the same service the timer starts, and read the service's journal.
Run the backup by hand and as a service
In ~/sched-lab, run backup.sh by hand, then the same backup as the lab-backup service, and read the service's journal.
First, predict
By hand, the script saved an archive. What will sudo systemctl start lab-backup.service answer?
Now start the exercise, run the command and compare your prediction with the output.
By hand, backup.sh found data and archive, while inside the service tar says No such file or directory. Why?
-
The unit has
User=student— check withsystemctl cat lab-backup.service. And root would open student's directories without errors. -
The script's first line,
#!/bin/bash, picks bash inside the service too. tar started — those are its lines in the journal.
The data and archive/… paths are relative, and the service has a different current directory.