
Cron Job
A cron job is a task that a computer automatically executes at set times, for example every night at three o'clock. The name comes from the program "cron," which has been managing such schedules on servers for decades.
A cron job is a task given to a computer that repeats itself over and over on its own. You set it up once: Run this command every day at 3:00 AM. After that, the computer takes care of it entirely by itself, without anyone having to press a button. The name comes from the program “cron,” which runs in the background on many servers and keeps an eye on the clock. A server, in this context, is simply a computer that is constantly switched on and provides services to others. You can think of a cron job as a very reliable alarm clock that doesn’t ring, but instead does a piece of work itself.
Why nobody wants to press buttons at night
Many tasks on a computer are boring but important. Data needs to be backed up. Invoices need to be sent. Old files need to be deleted so the hard drive doesn’t fill up. These are exactly the kinds of tasks that people forget or put off.
This is precisely where the value of a fixed schedule lies. A machine forgets nothing, it’s there on weekends, and it doesn’t complain about the time of day. As it happens, at three o’clock in the morning there is very little going on on many systems. Computationally intensive work doesn’t bother anyone then, because hardly any users are online.
For companies, this is also a matter of cost. Anyone who automatically creates a backup every night loses at most one day’s work in the event of a hard drive failure. Without automation, that same level of safety depends on the discipline of individual people. That’s why the rule is: whatever needs to happen regularly shouldn’t rely on people remembering to do it.
Five asterisks for the schedule
The schedules are stored in a text file known as the crontab. Each line describes one job. First come five time specifications, followed by the command to be executed. The five values mean, in order: minute, hour, day of the month, month, day of the week.
An asterisk stands for “every value.” So the line “0 3 * * *” means: minute 0, hour 3, on every day, in every month, on every day of the week. That’s the classic three-in-the-morning job. If you write “*/15 * * * *”, the command runs every 15 minutes. This notation looks cryptic, but is quickly learned and has remained almost unchanged since the 1970s.
A common misconception: a cron job does not check whether the previous run has finished. If a job starts every minute but takes two minutes to complete, eventually many copies end up running at the same time. The time zone is also a typical source of errors, for instance during the switch to daylight saving time. And if the server is switched off, the scheduled run is simply skipped. For tasks that absolutely must be made up afterward, more elaborate tools are therefore needed.
From the newsletter email to the stock price
Cron jobs are invisible, but everywhere. The newsletter that lands in your inbox every Friday morning is very likely triggered by such a schedule. Price data on financial websites is also often fetched and recalculated at fixed intervals. Weather services, price comparison sites, and search engines all work on the same principle.
With AI applications, further cases come into play. A company might, for example, run new documents through a model every night to make them searchable. Such batch processing, as it’s called, stands in contrast to an immediate response to a single request. Batch runs are usually significantly cheaper, because computing power can be used more efficiently.
In the big cloud services, the thing often has a different name but works the same way. In Kubernetes, it’s called a CronJob; at Amazon Web Services, it’s referred to as scheduled rules. Even on an ordinary Windows machine, the principle exists as “Task Scheduler.” When tech news mentions a “nightly job” that updates data, it is almost always this old, very robust tool behind it.