Home/Glossary/Cron job

Cron job

A scheduled task executed automatically at specific intervals or times by the cron daemon in Unix-like operating systems.

A cron job is a specific task scheduled for automatic execution by the cron daemon in Unix-like operating systems. The daemon runs as a background process and checks the crontab (cron table) files every minute to identify and trigger commands scheduled for the current system time and date.

How it works

The scheduling logic relies on a string format consisting of five time-and-date fields followed by the command. These fields represent minutes (0-59), hours (0-23), day of the month (1-31), month (1-12), and day of the week (0-6). Wildcards (*) are used to indicate "every," while specific values, ranges, or steps define precise execution windows.

Standard use cases for cron jobs in production environments include:

  • Database indexing and routine maintenance tasks;
  • Log rotation to prevent disk space exhaustion;
  • Automated security scans and system updates;
  • Periodic synchronization of files between remote servers.

For example, the entry 0 4 * * * /usr/bin/cleanup.py ensures a cleanup script runs daily at 4:00 AM. Using cron jobs eliminates the need for manual intervention in repetitive maintenance, ensuring system reliability and operational consistency.