Schedule scripts and maintenance jobs reliably using the cron daemon and crontab. 15.11.2025 | reading time: 2 min Cron runs scheduled commands on a predictable cadence; learn how to declare jobs, avoid common pitfalls, and make cron do the work while the administrator sleeps. Daily backup at 2:30 Create a small backup script and register it in crontab so the job runs every morning; for example, create the script and make it executable, then add a crontab entry as shown here: ```bash #!/bin/bash # /usr/local/bin/backup.sh echo "Starting backup" rsync -a /home /mnt/backup >> /var/log/backup.log 2>&1 ``` then set permissions and edit crontab: ```sh sudo chmod +x /usr/local/bin/backup.sh crontab -e # add the line below to the file 30 2 * * * /usr/local/bin/backup.sh crontab -l # expected output: 30 2 * * * /usr/local/bin/backup.sh ``` Verify and inspect results Check that the job ran by inspecting the log and the system cron logs; for Debian use `grep CRON /var/log/syslog` or on systemd hosts use `journalctl -u cron --since "1 hour ago"`, and always inspect the job's own log such as `/var/log/backup.log` to confirm success. Environment and robustness Cron jobs run with a minimal environment, so always use full paths or set `PATH` in the top of crontab, redirect stdout/stderr for debugging, prefer absolute paths in scripts, and consider `@reboot` or `@daily` shortcuts for readability. When cron is not enough For tasks that must survive reboots or run less frequently than every minute, or that need complex dependency ordering, try alternatives such as anacron, systemd timers, or at for one-shot runs. Ready to go further Start by automating a few simple maintenance tasks and iterate: more automation yields more time; if certification interests the administrator, consider CompTIA Linux+ or LPIC-1 and intensive exam preparation at bitsandbytes.academy to deepen practical skills. Join Bits & Bytes Academy First class LINUX exam preparation. scripting utilities backup