Linux + Bash Scripting
20 min
Day 11: cron & scheduled tasks; disk/memory/log inspection
cron: scheduling recurring work
cron runs commands on a fixed schedule defined by five time fields: minute, hour, day-of-month, month, day-of-week. 0 2 * * * means "at 02:00 every day."
crontab -e syntax
# m h dom mon dow command
0 2 * * * /opt/scripts/backup.sh
*/15 * * * * /opt/scripts/healthcheck.sh # every 15 minutesInspecting a live system
The four commands you'll run constantly
df -h # disk usage per filesystem
du -sh /var/log # size of a specific directory
free -h # memory: used, free, available, swap
tail -f /var/log/syslog # follow a log file liveThe number that actually matters
free -h's "available" column (not "free") is the real answer to "how much memory can a new process actually use" — Linux aggressively uses spare RAM for disk cache, which free -h counts separately but "available" already accounts for as reclaimable.
Key terms
- cron
- A time-based job scheduler for recurring commands.
- crontab
- A user's (or system's) table of scheduled cron jobs.
What does the cron schedule `*/15 * * * *` mean?