World map

 

BM: Baca dalam Bahasa Melayu

World L4: Remote Kitchens

Scheduled jobs: cron and timers

You will learn: to run a job on a schedule with cron, and with a systemd timer.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

kedai (lab)
crontab -l
0 2 * * * /home/you/backup.sh
crontab -l shows one line: 0 2 * * * /home/you/backup.sh

Someone must back up the menu at 2 a.m., every night. Nobody wants that shift. This one line does it. How?

Try it

cron: The shop's roster on the wall. It checks every minute and runs jobs on time. is the roster on the wall. It checks every minute. A roster line has five time fields, then the job. Put the fields in order.

First field at the top. Put these in order. Use the arrows, or drag.

  • minute (0-59)
  • hour (0-23)
  • month (1-12)
  • day of the month (1-31)
  • the command, with its full path
  • day of the week (0-7, Sunday is 0 or 7)

Try it

jobs.txt holds a roster line for every minute. Install it with crontab jobs.txt. Then sleep 15 until a minute passes, and read cron.log.

You are you in /home/you. 2 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~$

Folder ~

  • hello.sh (file)-rwxr-xr-xcan run
  • jobs.txt (file)-rw-r--r--

+ 3 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Predict

What does */15 * * * * mean?

Pick one answer.

Watch

kedai (lab)
cat /etc/systemd/system/kedai-backup.timer
[Unit]
Description=Back up the Kedai menu every night
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
[Install]
WantedBy=timers.target
sudo systemctl enable --now kedai-backup.timer
Created symlink '/etc/systemd/system/timers.target.wants/kedai-backup.timer' → '/etc/systemd/system/kedai-backup.timer'.
systemctl list-timers kedai-backup.timer
NEXT LEFT LAST PASSED UNIT ACTIVATES
Mon 2026-11-02 02:00:00 UTC 13h - - kedai-backup.timer kedai-backup.service
A timer file with OnCalendar 02:00 and Persistent=true. enable --now creates a symlink. list-timers shows the next run, Mon 2026-11-02 02:00 UTC, which starts kedai-backup.service.

systemd has its own alarm clock: a systemd timer: systemd's own alarm clock. It starts a service on a schedule and logs to the journal.. It starts a service on time. Persistent=true catches up on a run missed while the machine was off.

Check

cron or a systemd timer?

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now schedule a job with cron or a systemd timer.

      Go deeper (optional)

      cron runs with a tiny PATH and no terminal. Use full paths, and save output: >> /home/you/backup.log 2>&1. crontab -r deletes your whole roster without asking. systemd-analyze calendar '*-*-* 02:00:00' tells you when a timer fires next. Timer outputs here came from a real Debian 13 lab.

      Real mission

      1. echo '* * * * * date >> /tmp/tick.log' | crontab -
      2. cat /tmp/tick.log
      3. crontab -r
      4. systemctl list-timers

      0 of 4 steps done · Your ticks are saved.