cron is a time-based job scheduler in Unix-like operating systems. It enables users to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. These schedules are stored in crontab files, which use a specific format consisting of five time-and-date fields followed by the command to be executed.
The crond daemon runs in the background and checks the /etc/crontab file and the /var/spool/cron/crontabs directory every minute. When it finds a task whose scheduled time matches the current system time, it executes that task. Output from these tasks is typically sent to the local mail system unless redirected to a log file.
Common use cases include automated system maintenance, such as rotating log files, updating software packages, or performing nightly backups. It is also used for application-level tasks like sending scheduled emails or processing queues.
How it works
0 4 * * * /usr/bin/certbot renew— attempts to renew SSL certificates every day at 4:00 AM.@hourly /usr/local/bin/sync_data.sh— a shorthand alias to run a script at the start of every hour.
A key technical constraint is that cron does not load the user's full profile; therefore, environment variables like $HOME or $PATH may differ from an interactive shell session.