21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

What is a cron job?

Quick answer

A cron job is a scheduled command on a Linux server. The cron daemon checks the crontab every minute and runs any line whose five time fields — minute, hour, day of month, month and day of week — match the clock. Site owners use it for backups, cleanup, imports and WordPress scheduled posts.

For website owners and developers on Linux hosting who need to schedule, debug or replace a recurring task.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
6
Updated
14 Nov 2026
Written by
WebJi® team

What is a cron job in plain terms?

A cron job is one line in a schedule file: a time pattern followed by a command that the server runs whenever the pattern matches the clock. The cron daemon checks every minute, so jobs run at night, on weekends and when nobody is logged in.

The four cron terms people mix up
TermWhat it is
cronThe time-based job scheduler found on Linux and other Unix-like systems
crond (or cron)The background daemon that wakes every minute and starts matching jobs
crontabThe per-user table of scheduled lines, and the command that edits it
cron jobA single scheduled line: five time fields plus a command

Web hosting accounts in India almost always run Linux, so this is the scheduler your site uses. Windows servers use Task Scheduler for the same job, with a different interface and syntax.

How does crontab syntax work?

Each crontab line has five time fields — minute, hour, day of month, month, day of week — followed by the command. Standard cron has no seconds field, so one minute is the shortest interval it can express.

# ┌ minute (0–59)
# │ ┌ hour (0–23)
# │ │ ┌ day of month (1–31)
# │ │ │ ┌ month (1–12)
# │ │ │ │ ┌ day of week (0–7, 0 and 7 = Sunday)
# │ │ │ │ │
  30 2 * * * /usr/local/bin/php /home/USER/public_html/cron.php

Four operators build every schedule. An asterisk means every value; a comma lists values (1,15); a hyphen gives a range (1-5 is Monday to Friday in the weekday field); a slash sets a step (*/15 in the minute field is every 15 minutes).

Common cron schedules and when they run (server time)
ExpressionRuns
*/15 * * * *Every 15 minutes
0 * * * * or @hourlyAt minute 0 of every hour
30 2 * * *Daily at 02:30
0 */12 * * *At 00:00 and 12:00
0 9 * * 1-5At 09:00, Monday to Friday
0 0 1 * * or @monthlyMidnight on the 1st of each month

When both day of month and day of week are restricted, cron runs the job if either matches: 0 9 1 * 1 runs on the 1st and on every Monday, not only on Mondays that fall on the 1st. More patterns are collected in crontab examples for Linux.

How do you add a cron job in cPanel?

In cPanel, open Advanced → Cron Jobs, choose or type the five time fields, enter the full command, and select Add New Cron Job. cPanel runs it as your account user, which is what a shared hosting job should do.

  1. Under Cron Email, enter the address that should receive the job’s output, or leave it and silence output later.
  2. Pick a Common Setting such as “Once Per Day”, or fill Minute, Hour, Day, Month and Weekday yourself.
  3. In Command, use absolute paths: /usr/local/bin/php /home/USER/public_html/cron.php.
  4. Select Add New Cron Job; the line appears under Current Cron Jobs, where you can edit or delete it.

To stop the emails once the job is proven, end the command with >/dev/null 2>&1, or send output to a log file instead. WebJi® cPanel hosting and shared hosting plans include this Cron Jobs screen.

How do you manage cron jobs from the Linux command line?

Use crontab -e to edit your schedule, crontab -l to list it and crontab -r to remove it entirely. On a VPS these commands edit the crontab of whichever user you are logged in as.

crontab -l                      # show current jobs
crontab -e                      # open your crontab in the default editor
crontab -l > ~/cron-backup.txt  # back up before editing
sudo crontab -u www-data -l     # list another user's jobs (root only)

Be careful with -r: it deletes every line without asking, and the e and r keys sit next to each other. System-wide jobs live in /etc/crontab and /etc/cron.d/, where each line has an extra field naming the user to run as. If you need shell access first, what is SSH covers logging in.

Which website tasks should run as cron jobs?

Anything that must happen on a clock rather than when a visitor arrives: backups, cleanup, imports, reminder emails and framework schedulers. Use the interval the application documents, not the shortest one cron allows.

  • Backups: a nightly mysqldump copied off the server; for managed copies see server backup solutions.
  • Cleanup: deleting session or temp files older than a day with find … -mtime +1 -delete.
  • Framework schedulers: Laravel needs * * * * * cd /path && php artisan schedule:run; Magento writes its own entry with bin/magento cron:install.
  • WordPress: replace page-load triggered wp-cron with a real job.

WordPress’s built-in wp-cron only fires when someone loads a page, so a quiet site misses scheduled posts. Set define( 'DISABLE_WP_CRON', true ); in wp-config.php, then add a real job:

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

The full walkthrough, including the URL-based alternative, is in how to disable wp-cron.

How do you check whether a cron job actually ran?

Look for two separate facts: the system log showing cron started the line, and the job’s own output showing the command succeeded. One without the other proves very little.

  • Output to a log: append >> /home/USER/logs/cron.log 2>&1 and read the file after the scheduled minute.
  • cPanel email: anything the command prints arrives at the Cron Email address; no email means no output, not necessarily success.
  • VPS system log: grep CRON /var/log/syslog on Debian or Ubuntu, /var/log/cron on AlmaLinux or Rocky, or journalctl -u cron where journald is used.

A “command not found” message almost always means a relative path. Cron runs with a minimal PATH, so write /usr/local/bin/php, not php.

Why does a cron job run at the wrong time, twice, or not at all?

The usual causes are the server timezone, overlapping runs, an unescaped percent sign, or a server that was off at the scheduled minute. Each has a simple fix.

  • Timezone: cron follows the server clock. If it runs on UTC, 02:00 IST is 20:30 UTC the previous evening, so write 30 20 * * *. Check with date.
  • Overlap: a job longer than its interval starts a second copy. Wrap it with flock -n /tmp/job.lock /home/USER/script.sh so a new start is skipped while the old one holds the lock.
  • Percent signs: cron treats % as a newline. Escape it in commands such as date +\%F, or move the command into a script.
  • Missed runs: classic cron does not catch up after downtime; anacron or a systemd timer with Persistent=true does.

If the cause is still unclear on a WebJi® server, email support@webji.services with the cron line and the log output; support replies 24/7 in Hindi and English.

FAQ

Frequently asked questions

What is the difference between a cron job and a batch job?

A cron job starts because the clock matched its time fields. A batch job starts because work was submitted to a queue, and it may wait until resources are free. Cron can launch a batch process, but the trigger is time, not workload.

Can a cron job run every few seconds?

Not directly. One minute is the smallest unit in standard cron. For a 30-second task you can add two lines, one with sleep 30; before the command, or use a systemd timer or a long-running worker process instead.

Do cron jobs keep running if I close my SSH session?

Yes. The cron daemon runs independently of any login, so saved jobs continue after you log out or close the terminal. They stop only if you remove the line, the user account is disabled, or the cron service itself is stopped.

What is the cron equivalent on Windows hosting?

Task Scheduler. On Windows servers with Plesk, the Scheduled Tasks screen sets up the same kind of timed command, script or URL fetch. The time-field syntax differs, but the rules about full paths and logging output apply just the same.

Last editorial update: 14 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.