Background Jobs & Queues

Cron Expression Cheat Sheet: Syntax, Patterns, and Debugging

By Domain India Team · DomainIndia SupportPublished 10 min read
Knowledge base article
Contents (8 sections)

A cron expression is the five-field schedule that tells a Linux server when to run a command. Once you can read the five fields, you can write any schedule from "every 15 minutes" to "9 a.m. on weekdays". This cheat sheet covers the syntax, the patterns people use most, the rules that apply on Domain India shared hosting, and a checklist for jobs that silently refuse to run.

Key takeaways

The five fields are minute, hour, day of month, month and day of week, followed by the command: 30 2 runs every day at 2:30. Use for "every", /15 for "every 15", 1-5 for a range and 1,15 for a list. On Domain India cPanel and DirectAdmin shared hosting, schedules run in Indian Standard Time, and the shortest interval that takes effect is every 4 minutes: jobs set to every 1, 2 or 3 minutes are changed to /4. Always use full paths, and escape % as \%.

1. The five fields

text
 ┌──────────── minute        (0-59)
 │ ┌────────── hour          (0-23)
 │ │ ┌──────── day of month  (1-31)
 │ │ │ ┌────── month         (1-12 or JAN-DEC)
 │ │ │ │ ┌──── day of week   (0-7, where 0 and 7 are Sunday, or SUN-SAT)
 │ │ │ │ │
 * * * * *  command-to-run

Every field accepts the same building blocks:

SyntaxMeaningExample
NumberOne exact value5
RangeEvery value in the range1-5
ListSeveral values1,15,30,45
StepEvery Nth value*/10 (0, 10, 20 …)
Step in a rangeEvery Nth value inside a range0-30/5 (0, 5 … 30)
WildcardEvery value*
NameMonth or weekday namesMON-FRI, JAN

2. Three rules that trip people up

  • Steps restart every hour, day or month. */5 in the minute field means minutes 0, 5, 10 … 55, then 0 again. 0 */2 * * * means minute 0 of every second hour, not every 2 minutes.
  • Day of month and day of week combine with OR. If both fields are restricted, the job runs when either matches. 0 9 1 * 1 runs on the 1st of the month and on every Monday, not only on Mondays that fall on the 1st.
  • L, W, # and seconds fields are not standard cron. They belong to schedulers such as Quartz. Linux cron rejects them. "Last day of the month" needs a small check in the command instead (see section 4).

To double-check an expression, paste it into a cron explainer such as crontab.guru, which shows the next run times in plain English.

3. The everyday cheat sheet

ExpressionRuns
/5 *Every 5 minutes (:00, :05, :10 …)
/15 *Every 15 minutes
0,30 On the hour and at half past
0 At the start of every hour
0 /6 Four times a day: 00:00, 06:00, 12:00, 18:00
30 3 *Every day at 3:30 a.m.
0 9 1-59 a.m. on weekdays
0 9 0,69 a.m. on Saturday and Sunday
0 0 0Midnight every Sunday
0 0 1 Midnight on the 1st of every month
0 0 1 /3 Quarterly: 1 January, April, July and October
0 0 1 1 *Once a year, midnight on 1 January

Many cron versions also accept shortcuts: @hourly, @daily, @weekly, @monthly and @yearly (the same as 0 * * * *, 0 0 * * *, 0 0 * * 0, 0 0 1 * * and 0 0 1 1 *), plus @reboot, which runs once when the server starts. On shared hosting, write the five fields in full; @reboot only makes sense on a server you control.

4. Cron on Domain India shared hosting

We checked our cPanel and DirectAdmin shared servers in September 2026. Three rules apply to every account.

Every 4 minutes is the minimum on shared hosting

An hourly check on our cPanel and DirectAdmin shared servers rewrites any job set to run every 1, 2 or 3 minutes as /4, every 4 minutes. So really runs every 4 minutes. Use */5 or longer if you want the timing to be exactly what you typed. If a task truly needs to run every minute, use a VPS.

  • Time zone: the servers run on Indian Standard Time, so 30 2 * * * means 2:30 a.m. IST. India does not use daylight saving time, so jobs never skip or repeat an hour.
  • Where to add jobs: in cPanel, open Cron Jobs in the Advanced section; in DirectAdmin, open Cron Jobs from the advanced tools. You do not need SSH. For Webuzo, ask support for the right command paths before you schedule a PHP script.
  • Same account, same limits: cron jobs run as your hosting user, inside your account's CPU and memory limits, and PHP's disabled functions apply to them too. See PHP disabled functions on shared hosting.

The full walk-throughs are in how to set up a cron job for cPanel and setting up cron jobs in DirectAdmin.

Last day of the month. Standard cron has no "last day" field, so run the job on days 28 to 31 and let the command check whether tomorrow is the 1st:

bash
0 23 28-31 * * [ "$(date -d tomorrow +\%d)" = "01" ] && /bin/bash /home/USERNAME/scripts/month-end.sh

5. Real-world examples

Run a PHP script (cPanel). Name the PHP version and use full paths:

bash
*/15 * * * * /usr/local/bin/ea-php83 /home/USERNAME/public_html/cron.php >/dev/null 2>&1

On DirectAdmin, the PHP builds are at paths such as /usr/local/php83/bin/php.

WordPress. Add define( 'DISABLE_WP_CRON', true ); to wp-config.php, then run WordPress's scheduler every 15 minutes:

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

Laravel. Laravel asks for schedule:run every minute. On our shared servers that entry runs every 4 minutes, so write */4 yourself and check which of your tasks still run as intended; cron job commands explains exactly which Laravel frequencies survive.

bash
*/4 * * * * cd /home/USERNAME/laravel-app && /usr/local/bin/ea-php83 artisan schedule:run >/dev/null 2>&1

Call a URL. Add a changing value to the URL. Our cPanel servers cache ordinary web responses for up to two hours, and a repeated URL can be answered from that cache without your script running:

bash
*/15 * * * * /usr/bin/curl -s "https://example.com/cron.php?key=YOUR_KEY&t=$(date +\%s)" >/dev/null 2>&1

Clean up old logs. Delete .log files older than 30 days at 4 a.m.:

bash
0 4 * * * find /home/USERNAME/logs -name "*.log" -mtime +30 -delete

Nightly database dump. Keep the password out of the command line in a ~/.my.cnf file with permissions 600, then:

bash
30 2 * * * /usr/bin/mysqldump --single-transaction USERNAME_db | gzip > /home/USERNAME/backups/db-$(date +\%Y\%m\%d).sql.gz

6. When a cron job does not run

  1. Check the schedule.
    Read the expression back field by field, or paste it into an explainer. Remember the OR rule for the two day fields and the 4-minute minimum on shared hosting.
  2. Use full paths.
    Cron starts with an almost empty PATH and no current folder. Write /usr/local/bin/ea-php83, not php, and cd into the script's folder first if it includes files by relative path.
  3. Capture the output.
    Replace >/dev/null 2>&1 with >> /home/USERNAME/cron.log 2>&1 and read the log after the next run. The real error is almost always there.
  4. Escape every %.
    In a crontab line, a bare % ends the command. Write date +\%Y\%m\%d. Inside a script file, no escaping is needed.
  5. Set the environment yourself.
    Cron does not read ~/.bashrc. Put the variables a script needs at the top of the script, or in a file with permissions 600 that the script reads.
  6. Stop overlaps.
    If a run can take longer than the interval, wrap it in flock so a second copy exits instead of piling up: /usr/bin/flock -n /home/USERNAME/tmp/job.lock /bin/bash /home/USERNAME/scripts/job.sh.
  7. Check the time zone.
    On our shared servers it is IST. On a VPS, run timedatectl, and set it with sudo timedatectl set-timezone Asia/Kolkata if you want IST.

On a VPS you can also confirm that the cron service is running (systemctl status cron on Ubuntu or Debian, systemctl status crond on AlmaLinux or Rocky Linux) and read the system log. On shared hosting the cron service is run for you, and the server's cron log is not available to your account, so rely on your own log file.

7. Security, monitoring and when cron is the wrong tool

  • Keep secrets out of crontab lines. Anyone who can read your crontab or see the process list sees them. Read them from a file with permissions 600.
  • Monitor important jobs. Have the job call a heartbeat URL from a monitoring service, such as Healthchecks.io, at the end of each successful run, so you are alerted when it stops.
  • Review your jobs now and then. Delete ones you no longer need; each run uses your account's resources.

Cron is for scheduled, short tasks. For work that must run more often than every few minutes, a queue worker that runs all the time, or jobs that depend on each other, use a long-running process on a VPS (with systemd timers or a process manager) or the App Platform.

Frequently asked questions

What do the five fields in a cron expression mean?

In order: minute (0-59), hour (0-23), day of month (1-31), month (1-12) and day of week (0-7, where 0 and 7 are Sunday). The command follows the fifth field. For example, 30 2 * runs every day at 2:30.

How do I run a cron job every 5 minutes?

Use /5 * followed by your command. It runs at minutes 0, 5, 10 and so on through 55, every hour.

Can I run a cron job every minute on Domain India shared hosting?

No. On our cPanel and DirectAdmin shared servers, jobs set to run every 1, 2 or 3 minutes are changed to every 4 minutes by an hourly check, so 4 minutes is the shortest interval. For a job every minute, use a VPS.

Which time zone do cron jobs use on Domain India hosting?

Indian Standard Time on our cPanel and DirectAdmin shared servers, so 0 9 * runs at 9 a.m. IST. On a VPS, the time zone is whatever you set on the server.

Why does my cron job work in the terminal but not in cron?

Cron runs with a minimal environment: a short PATH, no current folder and no shell profile. Use full paths for the program and the script, escape every % as \%, and send the output to a log file to see the real error.

Can cron run a job every few seconds?

No. Standard cron works in whole minutes. For tasks more frequent than that, use a long-running process or a systemd timer on a VPS.

What happens if I set both the day of month and the day of week?

The job runs when either field matches. 0 9 1 * 1 runs on the 1st of every month and on every Monday.

How do I stop cron emails?

Add >/dev/null 2>&1 to the end of the command, or send the output to a log file. In cPanel you can also clear the Cron Email address at the top of the Cron Jobs page.

Ready to schedule your first job? Follow how to set up a cron job in cPanel, compare cPanel hosting plans, or open a support ticket with your cron line and the error from your log if a job will not run.

Hosting that runs your scheduled tasks

Cron jobs, several PHP versions and weekly backups on every shared hosting plan, managed from your control panel without SSH.

See cPanel hosting plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app