Linux Labs

Bash: text processing and scripts / Stage 8 of 9

A script on a schedule: environment, log, lock

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 6 · summary · 2 min

Summary

  • A service starts in the / directory, with a short PATH and none of your login's settings: relative paths and programs from ~/bin are not found inside it. WorkingDirectory= sets the service's directory.
  • A script's output and errors inside a service go to the service's journal, and its exit status decides whether the run succeeded.
  • flock -n at the top of a script lets one copy through — started by the timer or by hand — and the second exits at once with status 1.
  • backup.sh from the start of the lesson worked by hand and failed as a service because it looked for data and archive in the current directory, and for a service that is /.
Ubuntu 24.04
Loading…