Talk to the NOC, IST hours — +91 75994 50220 support@bigdomainhost.com
Guide

Cron jobs explained, and how to set one up

A cron job is a command your server runs on a schedule. The concept takes a minute; the five-field syntax is what trips everyone up. Here is both, plus the four reasons a cron that looks right does not run.

Short answer: A cron job is a command scheduled to run automatically at fixed times or intervals. Backups at 2am, an invoice run on the first of the month, a feed imported every fifteen minutes — anything that should happen without someone remembering to do it.

What it is

Cron is the scheduler that has been part of Unix since the 1970s. It reads a table of jobs — the crontab — and runs each command when its schedule comes round. That is the whole idea.

What people use it for, in practice: nightly backups, clearing temp files, importing a supplier feed, sending invoice reminders on the first of the month, renewing certificates, and driving WordPress's scheduler properly.

The five fields

┌───────────── minute        (0 - 59)
│ ┌─────────── hour          (0 - 23)
│ │ ┌───────── day of month  (1 - 31)
│ │ │ ┌─────── month         (1 - 12)
│ │ │ │ ┌───── day of week    (0 - 6, Sunday = 0)
│ │ │ │ │
* * * * *  /usr/bin/php /home/user/script.php

Four operators, and that is the entire syntax:

  • * — every value. * * * * * is every minute.
  • , — a list. 0 9,17 * * * is 9am and 5pm.
  • - — a range. 0 9-17 * * * is hourly from 9am to 5pm.
  • / — a step. */15 * * * * is every fifteen minutes.

Common cron expressions

Jump to: every 5 minutes · every 15 minutes · every hour · daily · weekly · monthly · list cron jobs · cron job not running

ExpressionRuns
* * * * *Every minute — the shortest interval cron allows; use it for testing
*/5 * * * *Every 5 minutes, at :00, :05, :10 and so on
*/10 * * * *Every 10 minutes
*/15 * * * *Every 15 minutes — the usual WP-Cron replacement
*/30 * * * *Every 30 minutes, at :00 and :30
0 * * * *Every hour, on the hour
0 */6 * * *Every 6 hours: midnight, 6am, noon and 6pm
30 2 * * *2:30am daily — the classic backup slot
0 0 * * *Daily at midnight
0 9 * * 1-59am on weekdays only
0 3 * * 03am every Sunday
0 0 1 * *Midnight on the first of every month

A step counts from the start of its range, not from when you saved the job: */5 in the minute field always fires at :00, :05, :10 and so on through :55. To run every 5 minutes but start at :02 instead, write 2-59/5 * * * *. Most crons also accept shortcuts such as @hourly, @daily, @weekly and @reboot, which save typing but are harder to read at a glance in a long crontab.

Cron runs in the server's timezone. On our servers that is IST, so 30 2 * * * is 2:30am in India, not UTC. Check with date before you assume.

Setting one up in cPanel

  1. cPanel → Cron Jobs.
  2. Put an address in Cron Email. Cron mails you anything the command prints, which is how you find out it has been failing for three weeks.
  3. Pick a Common Setting, or type the five fields yourself.
  4. Enter the command with absolute paths:
    /usr/local/bin/php /home/username/public_html/cron.php
  5. Add the job, then wait for the first run and check the mail.

To silence a job that works and prints noise, append >/dev/null 2>&1 — but only once you have seen it succeed.

On a VPS

# edit your own crontab
crontab -e

# list what is scheduled
crontab -l

# run as another user
sudo crontab -u www-data -e

System-wide jobs live in /etc/cron.d/ and take an extra field — the user to run as — between the schedule and the command. That difference catches people out constantly. If your jobs are heavy and run all day, such as big imports or reports, a Bigdomainhost VDS reserves whole physical cores for you, so run times stay steady.

How to list cron jobs in Linux

There is no single command that shows every scheduled job on a server, because cron reads from several places. To check cron jobs properly, look at each:

# your own jobs
crontab -l

# another user's jobs (needs root)
sudo crontab -u www-data -l

# every user's crontab at once
sudo ls /var/spool/cron/crontabs/   # Debian and Ubuntu
sudo ls /var/spool/cron/            # AlmaLinux and Rocky

# system-wide jobs
cat /etc/crontab
ls /etc/cron.d/ /etc/cron.hourly/ /etc/cron.daily/ /etc/cron.weekly/ /etc/cron.monthly/

crontab -l answering "no crontab for user" does not mean nothing runs — the job may sit in /etc/cron.d/ or belong to another user. On a modern distribution, also run systemctl list-timers: some scheduled work is a systemd timer rather than a cron entry. In cPanel, the Cron Jobs page lists the account's jobs under Current Cron Jobs, where you can edit or delete each one.

Cron job not running? The four usual reasons

First rule out the obvious: if no job on the server runs at all, the cron daemon itself may be stopped. Check it with systemctl status cron on Debian and Ubuntu, or systemctl status crond on AlmaLinux and Rocky. If the daemon is running and only your job is silent, it is almost always one of these four.

1. Relative paths

Cron runs your job from your home directory, not the folder you tested it in, and does not have your shell's PATH. php script.php fails; /usr/local/bin/php /home/user/script.php works. Find the binary with which php and use what it prints.

2. A missing environment

Your interactive shell loads .bashrc; cron does not. Anything that depends on an environment variable needs it set in the crontab itself:

PATH=/usr/local/bin:/usr/bin:/bin
30 2 * * * /home/user/backup.sh

3. The script is not executable

chmod +x /home/user/backup.sh, and make sure the first line is a shebang: #!/bin/bash.

4. An unescaped percent sign

The one nobody guesses. In a crontab, % means a newline. A command containing date +%Y-%m-%d is silently cut off at the first percent. Escape every one as \%.

WordPress: replace WP-Cron

WordPress's scheduler is not cron. It fires when someone loads a page, so on a quiet site scheduled posts do not publish and backups do not run — and on a busy site it fires on every page load, which is its own problem.

Fix both at once. In wp-config.php:

define('DISABLE_WP_CRON', true);

Then add a real cron job every fifteen minutes:

*/15 * * * * /usr/local/bin/php /home/user/public_html/wp-cron.php >/dev/null 2>&1

This is one of the highest-value five-minute changes on a WordPress site, and it is covered in more depth in our WordPress speed guide.

Debugging one that has gone quiet

  • Check the cron log — /var/log/syslog on Ubuntu, journalctl -u cron on Debian 12 and later, /var/log/cron on AlmaLinux and Rocky.
  • Redirect output to a file and read it: >> /home/user/cron.log 2>&1.
  • Run the exact command by hand first. If it fails interactively, cron was never the problem.
  • Test with * * * * * so you find out in a minute rather than tomorrow, then set the real schedule.

Cron jobs are available on every plan we sell, from Web & cPanel hosting upwards. If one will not behave, call +91 75994 50220 and we will look at it with you.

Sources (checked )

How Bigdomainhost can help

For scheduled jobs you control end to end, a KVM VPS gives you full root access, so every crontab command and systemd timer above works as written. Servers run on NVMe in Mumbai or Delhi NCR, a Linux VPS is usually ready in under 60 seconds, and billing is in 30-day periods with no setup fee. If a job has gone quiet and you cannot see why, our engineers answer WhatsApp at any time and the phone in IST hours.

See VPS plans Ask an engineer on WhatsApp

Answers

Frequently asked questions

Still unsure? Call +91 75994 50220 or write to support@bigdomainhost.com — a human replies in IST hours.

What is a cron job?

A command scheduled to run automatically at fixed times or intervals. Backups at 2am, an invoice run on the first of the month, a feed imported every fifteen minutes — anything that should happen without someone remembering to do it.

How do I read cron syntax?

Five fields before the command: minute, hour, day of month, month, day of week. An asterisk means every value. So 30 2 * * * is 2:30am daily, and */15 * * * * is every fifteen minutes.

How do I set up a cron job in cPanel?

cPanel → Cron Jobs. Pick a common setting or type the five fields, put the full command in the box, and set an email address for the output. Always use absolute paths — cron does not have your shell PATH.

Why is my cron job not running?

Almost always one of four things: a relative path instead of an absolute one, a missing PATH environment variable, the script not being executable, or an unescaped percent sign — in crontab, % means a newline and silently truncates your command.

What is WP-Cron and should I replace it?

WordPress has its own scheduler that fires on page loads, so on a quiet site scheduled posts and backups never run. Disable it in wp-config.php and call wp-cron.php from a real cron job every fifteen minutes instead.

How do I list cron jobs in Linux?

Run crontab -l for your own jobs and sudo crontab -u username -l for another user's. System-wide jobs live in /etc/crontab and /etc/cron.d/, so check those too, and run systemctl list-timers for anything scheduled as a systemd timer instead.

What is the minimum cron interval?

One minute, on standard cron. Anything finer needs a long-running process or a loop with sleep. On shared hosting the practical minimum is often five or fifteen minutes to protect the server.

Support that picks up the phone.

In IST hours, in Hindi or English, and WhatsApp replies fastest at any time. Sales, migration and emergencies all reach the same engineers. No offshore queue, no 48-hour first reply.

Want this done for you?

Migration is free and we do it. Call +91 75994 50220 or email support@bigdomainhost.com.