Linux Labs

Packages, services, and logs / Stage 11 of 13

Cron jobs and systemd timers

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 8 · on a machine · 4 min

Where schedules live

What you will learn

  • Find a machine's schedules in cron tables, system files and systemd timers.
  • Read and write a cron schedule line and check in the journal that a job ran.
  • Enable a systemd timer and tell its state apart from the service's state.

You have been handed a server. The previous admin writes: "There are no schedules on it, crontab -l is empty." Check whether that is true.

Exercise · look

Find the machine's schedules

Check three places: your own cron table, the system file /etc/crontab and the list of systemd timers.

First, predict

What will crontab -l print?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

Why did crontab -l print no crontab for student, although the machine does have schedules?

  • cron runs alongside the timers: it still launches the jobs in /etc/crontab. crontab -l knows nothing about timers at all.

  • systemctl is-active cron prints active. The no crontab output means student has no table of its own.

  • sudo crontab -l prints no crontab for root as well. root's jobs are in /etc/crontab, a system file rather than a user table.

crontab -l prints the user's personal table, while the machine's schedules are in /etc/crontab and the systemd timers.

Ubuntu 24.04
Loading…