Cron job 

Cron job: meaning, syntax and examples

Two people work at computers in an office, both focused on the screen.
Ralph Grundmann · Last updated on 3 October 2026

A cron job is a task that a server runs automatically at fixed times, for example every night at 3 am or every 15 minutes. It is handled by cron, a service that runs in the background on Linux and other Unix-like systems. Typical tasks are backups, sending reports, updating product data or clearing caches. The name comes from the Greek word “chronos”, meaning time.

What is a cron job?

A cron job consists of two parts: a schedule and a command. The schedule defines when something happens. The command defines what happens, usually a call to a script or program.

The key terms:

  • Cron: the service (daemon) that runs in the background and starts the tasks.
  • Crontab: the table that holds the tasks. Every user has their own crontab, and there is one for the system as a whole.
  • Cron job: a single line in the crontab, in other words one scheduled task.
  • Cron expression: the notation for the schedule, for example 0 3 * * * for “daily at 3 am”.

“Cron job” and “cronjob” mean the same thing. English usually writes two words; German often writes one.

How does cron work?

The cron service starts with the server and checks once a minute whether any crontab contains a task for that minute. If so, it runs the command with the permissions of the user who owns the crontab.

Three properties are worth knowing:

  • The smallest unit is the minute. Cron cannot schedule tasks by the second.
  • Cron does not catch up. If the server was switched off at the scheduled time, the task is skipped.
  • Cron does not know your login environment. Commands run with a very small environment. This is the most common reason why a script works by hand but not as a cron job.

Cron syntax: five fields and a command

Every line of the crontab has the same structure: five fields for the time, separated by spaces, followed by the command.

minute hour day month weekday command

  • Minute: 0 to 59
  • Hour: 0 to 23
  • Day of the month: 1 to 31
  • Month: 1 to 12 or jan to dec
  • Day of the week: 0 to 7 or sun to sat, where 0 and 7 both stand for Sunday

These characters are allowed in every field:

  • * stands for every value.
  • , separates several values: 1,15 in the day field means on the 1st and the 15th.
  • - defines a range: 1-5 in the weekday field means Monday to Friday.
  • / defines steps: */15 in the minute field means every 15 minutes.

One special rule often causes surprises: if both the day of the month and the day of the week are restricted, the task runs as soon as either matches. 0 8 13 * 5 therefore does not mean “Friday the 13th” but “on every 13th and on every Friday”.

There are shortcuts for common schedules: @hourly, @daily, @weekly, @monthly, @yearly and @reboot for “once after the server starts”.

Cron expression examples

The following expressions cover most cases and can be copied directly:

  • * * * * * every minute
  • */5 * * * * every 5 minutes
  • 0 * * * * on the hour, every hour
  • 30 2 * * * daily at 2.30 am
  • 0 8,18 * * * daily at 8 am and 6 pm
  • 0 7 * * 1-5 Monday to Friday at 7 am
  • 0 6 * * 1 every Monday at 6 am
  • 0 0 1 * * on the first of every month at midnight
  • 0 9 1 1,4,7,10 * on the first day of every quarter at 9 am
  • 0 22 * * 0 every Sunday at 10 pm

A complete line including the command looks like this:

30 2 * * * /usr/bin/php /var/www/shop/bin/feed-export.php >> /var/log/feed-export.log 2>&1

It starts a PHP script every night at 2.30 am and writes output and error messages to a log file.

Checking a cron expression: the cron generator

Enter a cron expression or choose an example. The tool explains each of the five fields and shows the next five runs in your local time. This lets you see whether the schedule is right before you add it to the crontab.

The tool supports the standard five-field syntax with *, lists, ranges, steps, names for months and weekdays, and shortcuts such as @daily. Seconds, years and special characters of other systems such as L, W or # are not supported.

Request a consultation

Setting up a cron job step by step

On a server with command line access, you set up a cron job in four steps:

  1. Open the crontab: the command crontab -e opens the crontab of the logged-in user in a text editor.
  2. Add a line: write the schedule and the command on a new line. Use full paths for programs and files.
  3. Save and close: cron picks up the change immediately. No restart is needed.
  4. Check: crontab -l lists all tasks. Test the task first with a time a few minutes in the future.

Be careful with crontab -r: the command deletes the entire crontab without asking.

Besides the user crontabs there are the system files /etc/crontab and the directory /etc/cron.d. There, the user under which the task runs is given between the schedule and the command.

Without a command line: with most hosting packages you create cron jobs in the control panel, for example in Plesk or cPanel. You select the schedule there and enter the command or the address of a script. The logic behind it is the same.

What are cron jobs used for when running a website?

Almost every larger website and every shop uses cron jobs, often without anyone noticing. Typical tasks:

  • Backups of the database and files
  • Product data: exporting and updating feeds for Google Shopping, price comparison sites and affiliate networks; see feed optimisation
  • XML sitemaps: regenerating them
  • Caches: clearing and warming them
  • Imports: synchronising stock levels and prices from the inventory system
  • Reports: retrieving data via an API and sending it as a report
  • Housekeeping: rotating or deleting old sessions, temporary files and log files
  • Emails: sending newsletters and notifications from a queue

This matters more for SEO than it sounds. If the cron job for the feed fails, Google shows outdated prices. If the sitemap is not regenerated, Google finds new pages later. A heavy cron job at peak time can slow the server and increase loading time. Tasks like these should run at night.

WordPress: WP-Cron and a real cron job

WordPress has its own system for scheduled tasks, WP-Cron. It publishes scheduled posts, checks for updates and runs tasks for plugins. However, WP-Cron is not a real cron job: it is not triggered by the clock but by page views. On every visit, WordPress checks whether tasks are due.

This has two drawbacks:

  • Few visitors: tasks run late or not at all. A post scheduled for 6 am only appears with the first page view after that.
  • Many visitors: the check runs with every request and costs performance. A page cache can also prevent WP-Cron from being triggered at all.

The solution is a real cron job. To do this, switch off the built-in trigger in the file wp-config.php:

define('DISABLE_WP_CRON', true);

A cron job on the server then calls the file wp-cron.php regularly, for example every five minutes:

*/5 * * * * wget -q -O /dev/null "https://www.example.com/wp-cron.php?doing_wp_cron"

Settings like these are part of our WordPress SEO work.

Troubleshooting: why is my cron job not running?

If a cron job does not run, or runs differently from what you expect, it is almost always down to one of these causes:

  1. Missing paths: cron only knows a few directories. Write programs with their full path, so /usr/bin/php instead of php, and do not use relative paths in the script either.
  2. Missing permissions: the script must be executable for the user of the crontab, and that user must be allowed to write to the target directories.
  3. Wrong time zone: cron follows the clock of the server. If it is set to UTC, a task scheduled for 8 am runs at 8 am UTC, not at your local time.
  4. The percent sign: in the crontab, % stands for a line break. In commands such as date +%F it must be written with a backslash: \%.
  5. No line break at the end: the last line must end with a line break. Without it, some versions of cron ignore the line or reject the crontab.
  6. No output: without redirection, error messages are lost or end up in a mailbox nobody reads. Redirect the output to a file: >> /var/log/task.log 2>&1.
  7. Overlapping runs: if a task takes longer than its interval, several copies run at the same time. The program flock prevents this.

The system log shows whether cron started the task at all. Depending on the system, grep CRON /var/log/syslog or journalctl -u cron helps. systemctl status cron shows whether the service is running; on some systems it is called crond.

Alternatives to cron

Cron has been the standard for decades, but it is not always the best choice:

  • systemd timers: available on modern Linux systems. They can catch up on missed runs, make tasks depend on one another and log by themselves.
  • anacron: for machines that do not run continuously. Missed daily or weekly tasks are caught up.
  • Windows Task Scheduler: the counterpart on Windows servers.
  • Cloud services: such as Cloud Scheduler at Google, EventBridge at AWS or CronJobs in Kubernetes. They use the same notation or a very similar one. EventBridge, for example, works with six fields, the sixth being the year.
  • External cron services: they call an address on your website at fixed intervals. Useful when the hosting does not allow cron jobs of its own.

You will also meet cron notation outside servers, for example in scheduled workflows in GitHub Actions or scheduled queries in databases. Once you have understood the five fields, you can read them anywhere.

Is your feed, your sitemap or your WordPress scheduling not running reliably? Then get in touch with us or read more about our technical SEO!

 Frequently asked questions 

Cron jobs: the key questions

What is a cron job in simple terms?

A cron job is a task that a server runs automatically on a schedule, for example a backup every night. The schedule is stored in a table, the crontab, and is checked once a minute by the cron service.

What does * * * * * mean in cron?

The five asterisks stand for minute, hour, day of the month, month and day of the week. An asterisk means “every value”. Five asterisks therefore mean: the task runs every minute.

What is the difference between cron, crontab and cron job?

Cron is the service that starts the tasks. The crontab is the table that holds the tasks and their schedule. A cron job is a single task, in other words one line of the crontab.

How often can a cron job run?

Once a minute at most. Shorter intervals need other tools, such as a permanently running service or a systemd timer.

Are there cron jobs on Windows?

Not cron itself. Windows uses Task Scheduler for the same purpose. Cron can, however, be used in the Windows Subsystem for Linux.

How can I see whether a cron job has run?

In the system log, depending on the system with grep CRON /var/log/syslog or journalctl -u cron. In addition, every task should write its output to its own log file.

 Request a consultation 

Questions about this topic?

Tell us briefly what it is about. You will speak directly to Ralph Grundmann.
Microsoft Partner Badge
SISTRIX certified agency
4.9
Based on 33 reviews
Request a consultation
Ralph Grundmann
Ralph GrundmannFounder and Managing DirectorCall: 0228 243 313 53

* Required

Please enter your name.

Please enter a valid email address, e.g. name@company.com.

For a call back.

Please enter your number with area code, e.g. 0228 243 313 53 or +49 228 243 313 53.

Please tell us briefly what it is about.

Free and without obligation. We usually reply within 24 hours on working days.

Information on how we process your data: Privacy policy