Automation — Cheat Sheet
Linux · 1 topics. Download the PDF or the Instagram carousel and share it.
Cheat Sheet · AiCanCode.org
Automation
Linux1 topicsQuick revision reference
1
Cron, at & Automation
cron runs commands on a schedule; at runs a command once at a specified future time. These are the standard Linux tools for backup jobs, report generation, and routine maintenance.
- ✓Crontab fields: minute hour day month weekday — remember with "minute or hour, day or month, weekday".
- ✓Always use absolute paths in crontab — cron runs with a minimal PATH.
- ✓Redirect cron job output to a log file: command >> /var/log/job.log 2>&1.
- ✓@reboot runs a command once at system startup — useful for background services.
- ✓Systemd timers offer journald logging, dependency management, and catch-up on missed runs.
- ✓crontab.guru is the fastest way to verify a cron expression.
Crontab time field syntax
# Crontab format: # ┌──────────── minute (0 - 59) # │ ┌────────── hour (0 - 23) # │ │ ┌──────── day of month (1 - 31) # │ │ │ ┌────── month (1 - 12) # │ │ │ │ ┌──── day of week (0=Sun, 6=Sat, 7=Sun) # │ │ │ │ │ # * * * * * command to execute # Examples: * * * * * /opt/scripts/heartbeat.sh # every minute 0 * * * * /opt/scripts/hourly-report.sh # every hour at :00 0 2 * * * /opt/scripts/backup.sh # daily at 2:00 AM 0 2 * * 0 /opt/scripts/weekly-cleanup.sh # Sundays at 2:00 AM 0 0 1 * * /opt/scripts/monthly-invoice.sh # 1st of every month, midnight */5 * * * * /opt/scripts/health-check.sh # every 5 minutes 0 9-17 * * 1-5 /opt/scripts/business-hours.sh # every hour, 9-5, Mon-Fri # Shortcuts @reboot /opt/scripts/startup.sh # on system boot @daily /opt/scripts/backup.sh # same as: 0 0 * * * @weekly /opt/scripts/cleanup.sh # same as: 0 0 * * 0 @monthly /opt/scripts/report.sh # same as: 0 0 1 * * # crontab.guru — visual cron expression editor online
Learn this free with Aria, your AI tutor → AiCanCode.org/learn/linux