Cron Job
A cron job is a command or script that runs automatically on a repeating schedule, such as every night at 2:00 or every Monday at 9:00. The schedule is written as a cron expression with five fields (minute, hour, day of month, month, day of week), and the cron scheduler on Linux, macOS and other Unix systems checks it every minute and starts the job when the time matches.
Understanding Cron Job
The name comes from Chronos, the Greek personification of time. Cron is a Unix utility that runs scheduled commands based on a configuration file (crontab) with expressions defining when each job should run. The syntax allows specification of minutes, hours, days, months, and days of the week.
A cron expression like '0 9 * * 1-5' means: at minute 0, hour 9, any day of month, any month, on weekdays (Monday-Friday), i.e., 9:00 AM on every weekday. This enables precise scheduling of recurring automated tasks.
Cron jobs power background automation: nightly database backups, hourly data syncs, daily report generation, weekly digest emails, and monthly billing cycles are all commonly implemented as cron jobs. For AI assistants, cron jobs trigger scheduled workflows like morning briefings, end-of-day summaries, and weekly review emails.
Modern cloud environments have moved beyond Unix cron to managed scheduling services (AWS EventBridge, Google Cloud Scheduler) and application-level schedulers (Celery Beat, APScheduler, ARQ). These offer better reliability, logging, and monitoring than raw cron.
Reading a cron expression: the five fields are minute (0-59), hour (0-23), day of month (1-31), month (1-12) and day of week (0-6, where 0 is Sunday). An asterisk means every value, a comma lists values (1,15), a hyphen sets a range (1-5) and a slash sets a step (*/15 in the minute field means every 15 minutes). Common examples: 0 2 * * * runs daily at 2:00, */15 * * * * runs every 15 minutes, 0 9 1 * * runs at 9:00 on the first day of each month, and 30 17 * * 5 runs on Fridays at 17:30. If you restrict both day of month and day of week, classic cron runs the job when either one matches, which surprises a lot of people.
Creating a cron job on Linux or macOS: run crontab -e to edit your user's crontab, add one line per job with the expression followed by the command (for example 0 2 * * * /home/me/backup.sh), save, and check the result with crontab -l. Cron starts jobs with a minimal environment, so use absolute paths, set PATH or other variables at the top of the file, and send output to a log file; otherwise errors disappear or land in a local mailbox nobody reads. Jobs run in the machine's time zone unless you configure another one.
Where cron falls short: it does not retry a failed job, it does not run jobs that were due while the machine was off (anacron and systemd timers can), and it does not stop two copies of a slow job from overlapping (wrapping the command in flock does). Kubernetes offers a CronJob resource with the same syntax for containers, and cloud schedulers such as AWS EventBridge Scheduler and Google Cloud Scheduler accept cron expressions too. When the trigger is something happening rather than a time, such as a new email or a new issue, event-driven automation fits better than a cron job.
How GAIA Uses Cron Job
GAIA workflows can run on a cron schedule. Tell GAIA the timing in plain words ("every weekday at 8am") or give a five-field cron expression, and the schedule is evaluated in your time zone. Each run is queued on ARQ, GAIA's Redis-based job queue, and the workflow's steps run in the background, with GAIA able to notify you about the result. A schedule can fire at most once an hour, so expressions that run every minute or every 15 minutes are rejected. Morning briefings, end-of-day summaries and weekly reviews are typical scheduled workflows.
Related Concepts
Workflow Automation
Workflow automation is the use of technology to execute repeatable business processes and tasks automatically, reducing manual effort and human error.
Event-Driven Automation
Event-driven automation (also called event-based automation) runs a workflow the moment something happens, such as a new email arriving, an issue being created or a row being added to a spreadsheet, instead of at a fixed time. Each automation pairs a trigger event with the actions to take, and the system where the event happened notifies the automation platform, usually through a webhook.
Task Automation
Task automation is the use of technology, particularly AI, to automatically create, manage, prioritize, and execute repetitive tasks that would otherwise require manual effort.
Webhook
A webhook is an HTTP callback mechanism where a system sends an automated HTTP request to a specified URL whenever a defined event occurs, enabling real-time notification and integration between services without polling.
