On this page
Much of what keeps your site alive doesn't happen at the press of a button: the backup taken at dawn, abandoned-cart emails, the sales report that arrives at 7 a.m., deleting the temporary files that eat up your storage. All of these are recurring tasks with fixed rules, and that is exactly what cron was designed for four decades ago, and every Linux server still runs it today. This guide explains the syntax character by character, then moves on to creating jobs in practice from your hosting panel, then ready-to-paste recipes, and ends with the things that most often make jobs fail and how to diagnose them yourself.
What is a cron job, and why do you need one?
Every Linux server runs a small background service called the cron daemon (or crond). Its only job is to wake up every minute, read the schedules stored on the server, and ask: is it time for any command right now? If the answer is yes, it runs it; otherwise it sleeps for another minute. That's all there is to it. The idea is almost naively simple, but it has been the backbone of all automation on servers since the 1980s.
The table this service reads is called a crontab (short for cron table). It is an ordinary text file in which each line represents one job: a schedule plus a command. A single job is called a cron job, and it is what you see in your hosting panel under "Scheduled tasks" or "Cron Jobs."
The fundamental difference between cron and any browser-based automation is independence from visitors. A site page only runs when someone requests it, whereas a cron job runs while the server sits completely silent at 3 a.m. This difference is not a technical detail: it is what makes scheduled backups reliable and gets periodic reports delivered on time.
| What you need | Without a cron job | With a cron job |
|---|---|---|
| A daily backup | You sometimes remember it and usually forget | Taken at dawn every day with no intervention |
| Deleting accumulated temporary files | You find the problem when storage fills up | Cleaned up automatically every night |
| A periodic sales report | You open the dashboard and calculate it by hand | Arrives in your inbox ready every morning |
| Publishing a post at a set time | You wait for the hour and click "Publish" | Published at the exact scheduled moment |
| Abandoned-cart emails | Never sent | Checked and sent every hour |
| Site health checks | You hear about the outage from a customer | Instant alert at the first failure |
This independence is also what makes cron the foundation layer on which newer automation tools are built. If you are thinking about something broader than a single command on one server, our article on automating repetitive tasks in your business lays out the full picture of choosing what is worth automating in the first place. Even those tools, at their core, rely on a time-based trigger not very different from what we explain here.
It's worth pointing out from the start that cron is not a replacement for the application but its timekeeping arm: a cron job doesn't "understand" your site or know what an abandoned cart is. It only runs a command at its scheduled time. All the logic stays in the script or plugin it calls. That leads to the practical rule that saves most of the trouble: first write a script that works correctly when you run it by hand, check its output, and then schedule it. Never the other way around.
How do you read the five-field schedule syntax?
This is where most beginners stumble, even though the rule is simpler than it looks. A cron line starts with five fields separated by spaces, followed by the command to run. The five fields are read from left to right in a fixed order that never changes: they start with the smallest unit of time (the minute) and end with the largest (the day of week).
A mnemonic that locks in the order: minute, hour, day, month, weekday. Each field accepts either a specific value or an asterisk *, which means "every possible value in this field."
| Position | Field | Allowed range | Example | What the example means |
|---|---|---|---|---|
| 1 | Minute | 0-59 | 30 | At minute 30 of the hour |
| 2 | Hour | 0-23 | 2 | 2 a.m. (24-hour clock) |
| 3 | Day of month | 1-31 | 15 | The 15th day of the month |
| 4 | Month | 1-12 | 6 | June |
| 5 | Day of week | 0-7 | 1 | Monday; 0 and 7 are both Sunday |
Watch out for two details that trip up many people. First, the hour uses the 24-hour clock, so there is no a.m. or p.m.: 8 p.m. is 20, not 8. Second, the day-of-week field starts from Sunday as 0, and 7 is also accepted and means the same Sunday. This leniency is deliberate in common cron implementations, because some systems count the week from Monday.
Most servers also accept short English names instead of numbers: JAN to DEC in the month field and SUN to SAT in the day-of-week field. So 0 3 * * SUN is exactly equivalent to 0 3 * * 0. Names are clearer to read, but numbers are safer on any server. More importantly, some implementations do not accept names inside a range with a step, so stick to numbers in compound expressions.
The four symbols you actually need
Beyond the asterisk, four symbols are enough to build almost any schedule. You don't need to memorize ready-made expressions if you understand these four, because they combine freely.
| Symbol | Meaning | Full example | What it means in plain English |
|---|---|---|---|
* | Every possible value in the field | * * * * * | Every minute, without exception |
, | A list of separate values | 0 8,14,20 * * * | 8 a.m., 2 p.m. and 8 p.m. |
- | A continuous range from one value to another | 0 9-17 * * * | Every hour from 9 a.m. to 5 p.m. |
/ | A step (every how many units) | */15 * * * * | Every 15 minutes |
- with / | A step within a specific range | 0 9-17/2 * * 1-5 | Every two hours from 9 to 17, Monday to Friday |
The step / is the most misunderstood. */15 in the minute field does not mean "15 minutes from now" but "at every minute divisible by 15," that is, minutes 0, 15, 30 and 45 of every hour, at fixed times unrelated to the moment you created the job. It is exactly equivalent to writing 0-59/15.
This leads to an edge case worth noting: a step that doesn't divide sixty evenly creates a gap at the top of the hour. */7 in the minute field runs the job at minutes 0, 7, 14, 21, 28, 35, 42, 49 and 56. Then the hour resets to zero, so the gap between the 56 and 00 runs is only four minutes instead of seven. The same applies to */45 and others. If a regular interval matters to you, stick to divisors of sixty: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30.
The , symbol solves a problem a range can't: non-adjacent times. You can't express "3 a.m. and 3 p.m." with a range, but 0 3,15 * * * does it in a couple of characters. You can also mix symbols within a single field: 0 0,6-9,18 * * * means midnight, then every hour from 6 to 9 a.m., then 6 p.m.
Common expressions and what they mean
This table is a quick reference to come back to whenever you need an expression. Check each expression by reading it field by field before saving it: a mistake in a single field turns a daily job into one that runs sixty times an hour.
| Expression | What it means exactly |
|---|---|
* * * * * | Every minute (you rarely actually want this) |
*/5 * * * * | Every 5 minutes |
*/15 * * * * | Every 15 minutes |
0 * * * * | At minute zero of every hour |
30 * * * * | At minute 30 of every hour |
0 */6 * * * | Every 6 hours (00:00, 06:00, 12:00, 18:00) |
0 3 * * * | 3 a.m. every day |
30 2 * * 1 | 2:30 a.m. every Monday |
0 0 * * 0 | Midnight on Sunday (start of the week) |
15 4 * * 5 | 4:15 a.m. every Friday |
0 2 * * 1-5 | 2 a.m. Monday to Friday |
0 8,20 * * * | 8 a.m. and 8 p.m. |
0 9 1 * * | 9 a.m. on the first day of every month |
0 0 1 1 * | Midnight on January 1 (yearly) |
0 22 28-31 * * | 10 p.m. on the last days of the month |
Note the last line: there is no direct way to express "the last day of the month," because months differ in length. The usual trick is to schedule the job on days 28 to 31, then put a check at the start of the script that continues if tomorrow is the first of the month and exits immediately otherwise.
How do you create a cron job from your hosting panel?
On shared hosting you won't need a terminal at all: the control panel provides a simple form. The steps on cPanel, which are similar in DirectAdmin, CyberPanel and others, are as follows.
Log in to your panel and search for Cron Jobs in the search box at the top. You'll usually find it under the "Advanced" section. If you're new to the panel, our article cPanel explained for beginners introduces all its sections and saves you from getting lost among the icons.
The first thing you see on the page is the Cron Email field: the email address that receives each job's output. Leave it empty or use an address dedicated to logs, not your main inbox. We'll come back to this point shortly, because it is what annoys site owners most.
Next you'll find a drop-down called Common Settings with ready-made schedules (every five minutes, every hour, daily, weekly…). Choosing one fills in the five fields for you, and it is the quickest route for a beginner. If you want a schedule that isn't in the list, fill in the fields manually one by one. They are laid out on screen in the same order we explained: Minute, Hour, Day, Month, Weekday.
The last and most important field is Command: the actual command to be run. Write it out in full with absolute paths, then click "Add New Cron Job." The job will appear in a table at the bottom of the page with Edit and Delete options.
Before you click Add, check three things: that the path you wrote actually exists, that the file is executable if it's a script, and that the interval you chose is allowed on your plan. This last point in particular varies between plans.
| Hosting type | Shortest allowed interval (typical) | Number of jobs allowed | Permissions |
|---|---|---|---|
| Budget shared | 15 minutes | 5 to 10 jobs | Your user only |
| Business shared | 5 minutes | 10 to 20 jobs | Your user only |
| Managed VPS | One minute | No practical limit | Your user, plus root when needed |
| VPS or dedicated server | One minute | Unlimited | Full, including root |
These limits are not arbitrary on the host's part; they protect the shared server. A heavy job running every minute on a hundred accounts means a hundred simultaneous processes. If you're not sure what a shared plan is and what its limits are, our explainer on shared hosting and how it works shows why these restrictions are imposed and when they become too tight for you. To understand how jobs affect your usage, see server resources and how they are measured.
What goes in the Command field?
This is where most mistakes happen. A command that works in your terminal may fail silently in cron, because cron's environment is not your environment: it doesn't read your .bashrc file, its PATH variable is very short (often just /usr/bin:/bin), and the working directory is the user's home directory, not the script's directory. The result is that php script.php works for you and fails in cron simply because cron doesn't know where php is.
So the rule is: absolute paths for everything: for the interpreter, the script, and the files it writes to.
Running a PHP file
This is by far the most common case. The syntax:
0 3 * * * /usr/local/bin/php -q /home/user/public_html/scripts/task.phpThe PHP path differs between hosting providers, and this is a very common cause of failure. Find the correct path on your server with a single command over SSH:
which php
# or find all available versions
ls -1 /usr/local/bin/ | grep -i php| Path | Where you'll find it |
|---|---|
/usr/local/bin/php | Most common on cPanel and CloudLinux servers |
/usr/bin/php | Most standard Linux distributions |
/opt/cpanel/ea-php82/root/usr/bin/php | A specific PHP version on EasyApache 4 |
/usr/local/bin/ea-php82 | cPanel shortcut for calling a specific version |
php on its own | Depends on PATH; unreliable inside cron |
The -q flag means "quiet mode" and stops HTTP headers from being printed in the output. You need it if the host maps the php command to the php-cgi binary instead of the command-line version; without it, the job's emails will be full of useless Content-type headers. Adding it is safe either way.
Running a Bash script
30 2 * * * /bin/bash /home/user/scripts/backup.shYou can drop /bin/bash if the script starts with a correct #!/bin/bash shebang line and its execute permission is set with chmod +x. But writing the interpreter explicitly removes the dependency on permissions and saves you an annoying diagnosis later.
Calling a URL on the site
Some plugins and systems expect a URL to be called instead of a file to be run. Use curl or wget with their absolute paths:
*/10 * * * * /usr/bin/curl -s "https://example.com/cron/run.php" >/dev/null 2>&1Watch out for two things: put the URL in quotes if it contains ? or &, and use -s with curl (or -q -O - with wget) to suppress the progress bar that pointlessly fills your logs. Also remember that this method goes through the web server, so it is bound by PHP's maximum execution time. It is not suitable for long-running jobs.
Ready-made recipes: backups, cleanup and reports
Here are three jobs that almost every site needs, written out in full and ready to adapt.
1) A daily backup of the database and files
Create the file /home/user/scripts/backup.sh:
#!/bin/bash
set -euo pipefail
STAMP=$(date +%F)
DEST=/home/user/backups
SITE=/home/user/public_html
mkdir -p "$DEST"
# database backup (credentials are read from ~/.my.cnf)
mysqldump --single-transaction --quick my_database > "$DEST/db-$STAMP.sql"
gzip -f "$DEST/db-$STAMP.sql"
# site files backup
tar -czf "$DEST/files-$STAMP.tar.gz" -C "$(dirname "$SITE")" "$(basename "$SITE")"
# delete backups older than 14 days
find "$DEST" -type f -mtime +14 -delete
echo "[$(date +'%F %T')] Backup completed successfully"Don't put the database password on the command line: any user on the server can see it in the process list. Put it instead in a ~/.my.cnf file with locked-down permissions:
# contents of the ~/.my.cnf file
[client]
user=my_db_user
password=your_password_herechmod 600 ~/.my.cnf
chmod +x /home/user/scripts/backup.shThen the crontab line:
30 2 * * * /bin/bash /home/user/scripts/backup.sh >> /home/user/logs/backup.log 2>&1This is a local copy on the same server, and it is not a complete backup strategy: a backup that lives on the same disk is lost with the disk. Read the website backup guide to understand the 3-2-1 rule and off-site storage destinations, and if you're on WordPress, the WordPress backup guide covers plugins and restoring in detail.
2) Cleaning up temporary files and logs
Accumulated temporary files consume both storage and your allowed file count (inodes), and can bring your site down for no apparent reason:
# delete temp files older than 7 days, daily at 4 a.m.
0 4 * * * /usr/bin/find /home/user/tmp -type f -mtime +7 -delete >/dev/null 2>&1
# trim the debug log if it grows too large, every Sunday
0 5 * * 0 /usr/bin/find /home/user/public_html/wp-content -maxdepth 1 -name "debug.log" -size +50M -delete >> /home/user/logs/cleanup.log 2>&13) A daily report sent by email
A PHP script that reads from the database and sends a summary. Save it as /home/user/scripts/daily-report.php:
<?php
// yesterday's sales report, run from cron via PHP CLI
$dsn = 'mysql:host=localhost;dbname=my_database;charset=utf8mb4';
$user = 'my_db_user';
$pass = getenv('DB_PASSWORD') ?: '';
try {
$pdo = new PDO($dsn, $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$since = date('Y-m-d 00:00:00', strtotime('-1 day'));
$until = date('Y-m-d 00:00:00');
$stmt = $pdo->prepare(
'SELECT COUNT(*) AS orders_count, COALESCE(SUM(total), 0) AS revenue
FROM orders
WHERE created_at >= :since AND created_at < :until'
);
$stmt->execute([':since' => $since, ':until' => $until]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$body = sprintf(
"Report for %s\nOrders: %d\nTotal sales: %s\n",
date('Y-m-d', strtotime('-1 day')),
$row['orders_count'],
number_format((float) $row['revenue'], 2)
);
$subject = '=?UTF-8?B?' . base64_encode('Daily sales report') . '?=';
$headers = "MIME-Version: 1.0\r\n"
. "Content-Type: text/plain; charset=UTF-8\r\n"
. "Content-Transfer-Encoding: 8bit\r\n";
mail('owner@example.com', $subject, $body, $headers);
echo "Report sent\n";
} catch (PDOException $e) {
// print the error so it is recorded in the job's log file
fwrite(STDERR, 'Report failed: ' . $e->getMessage() . PHP_EOL);
exit(1);
}And the crontab line:
0 7 * * * /usr/local/bin/php -q /home/user/scripts/daily-report.php >> /home/user/logs/report.log 2>&1Note the subject encoding in the =?UTF-8?B?...?= format: without it, non-ASCII subject lines, such as Arabic ones, arrive as garbled characters in most email clients. Note also exit(1) on failure: a non-zero exit code lets monitoring tools detect the job's failure automatically.
Cron jobs on a VPS: working with crontab directly
If you're on a VPS (virtual private server), you have full access, and you edit the table over SSH. If you're not yet comfortable with the terminal, SSH basics for beginners is the right starting point.
crontab -e # open your table for editing
crontab -l # list current jobs
crontab -l > ~/crontab-backup.txt # back up the table itself
crontab -r # delete all your jobs; dangerous, cannot be undoneMake a habit of taking a backup before any edit. The short distance on the keyboard between -e and -r has cost many people their entire tables.
You can also set the jobs' environment at the top of the crontab file, which is a neat fix for the minimal PATH problem:
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
MAILTO=""
0 3 * * * /home/user/scripts/backup.sh
*/10 * * * * /home/user/scripts/health-check.shTo make sure the cron service itself is running, a step many people skip before diagnosing the job itself:
systemctl status cron # on Debian and Ubuntu
systemctl status crond # on AlmaLinux, Rocky and CentOSManaging these services and reading their status is a topic in its own right, covered in the guide to managing services on Linux, which also compares cron with its modern alternative, systemd timers.
The practical form of locking inside a crontab line:
*/5 * * * * /usr/bin/flock -n /tmp/sync.lock /home/user/scripts/sync.sh >> /home/user/logs/sync.log 2>&1The -n flag means: if the lock is already taken, exit immediately instead of waiting. That's exactly what you want, because waiting for the previous job piles up processes instead of preventing them.
wp-cron vs. real cron: the difference that breaks sites
This is the part every WordPress site owner should read twice.
WordPress has an internal scheduling system called WP-Cron, which many functions rely on: publishing scheduled posts, checking for updates, cleaning up revisions, and scheduling plugin tasks such as sending emails and taking backups. The problem is that this system is not real cron and has nothing to do with the system service. It is just a list of tasks stored in the database, and WordPress only checks it when a page loads: on every visit, WordPress calls the wp-cron.php file in an internal request to ask, "Is any task overdue?"
The result is a strange inverse relationship that hurts both ends:
- A low-traffic site: no visits means no calls. A post scheduled for 6 a.m. isn't published until someone opens the site at noon. The "daily" backup becomes random. The order confirmation email is delayed for hours.
- A high-traffic site: every visit fires an extra internal HTTP request. Ten thousand visits a day means thousands of calls for a task that may only need to run twice. The impact on CPU and response time is direct, and it is one of the causes of slowness many people overlook. See speeding up WordPress for the other factors.
| Aspect | Built-in wp-cron | Real cron on the server |
|---|---|---|
| What triggers it | A page visit from a visitor or crawler | The operating system service |
| Timing precision | Approximate, follows visitor traffic | Precise to the minute |
| A site with no visits overnight | Tasks stop completely | Run as usual |
| A busy site | Repeated calls that consume resources | One call per schedule |
| Load on the server | Rises with traffic | Steady and predictable |
| Where it is configured | Inside WordPress, automatically | The hosting panel or crontab |
| Suitable for | Test and local sites | Every production site, without exception |
How to replace it the right way
Step one: disable the automatic call. Open the wp-config.php file in the site root (you can edit it from the panel's File Manager) and add the following line before the /* That's all, stop editing! */ line:
define('DISABLE_WP_CRON', true);Step two, and don't put it off for even a minute: create the replacement job:
*/10 * * * * /usr/bin/curl -s "https://example.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1Or with wget if curl isn't available:
*/10 * * * * /usr/bin/wget -q -O - "https://example.com/wp-cron.php?doing_wp_cron" >/dev/null 2>&1The better way: WP-CLI
If the WP-CLI command-line tool is available on your hosting (it is on most serious plans, and it is indispensable when fixing common WordPress errors), using it beats calling the URL for three reasons: it doesn't go through the web server, so it isn't subject to PHP's maximum execution time; it doesn't tie up a web worker; and it returns a clear exit code on failure.
*/10 * * * * cd /home/user/public_html && /usr/local/bin/wp cron event run --due-now >> /home/user/logs/wpcron.log 2>&1And some useful commands for manual checks over SSH:
wp cron event list # list scheduled events and their times
wp cron event run --due-now # run whatever is due now
wp cron test # check whether wp-cron works at allYou can use the same access for other periodic maintenance, such as optimizing the database tables weekly:
0 5 * * 0 cd /home/user/public_html && /usr/local/bin/wp transient delete --expired --quiet && /usr/local/bin/wp db optimize --quiet >> /home/user/logs/wp-maint.log 2>&1But be careful: optimizing tables is not a cure for every slowdown, and a database bloated with revisions and leftover data from deleted plugins needs a deeper cleanup, explained in optimizing the WordPress database.
Troubleshooting: why isn't my job running?
This section will save you hours. Always start with the table below, then drill down into the details.
| Symptom | Most likely cause | Fix |
|---|---|---|
| The job doesn't run at all | Wrong interpreter or script path | Use absolute paths and check with which php |
| Works manually, fails in cron | Cron's environment doesn't read PATH or .bashrc | Set PATH= at the top of the crontab |
| Runs 60 times an hour | You wrote * 3 * * * instead of 0 3 * * * | An asterisk in the minute field means every minute |
| Runs at an unexpected time | The server's time zone differs from yours | Check with date and work out the difference |
| Runs twice at the scheduled time | A duplicate job in both the panel and the crontab | Review both lists and delete the duplicate |
| Runs on unintended days | You restricted both day of month and day of week | Leave one of them as * |
| An annoying email after every run | Cron emails all of the job's output | Redirect the output to a log file |
| The script runs but doesn't write a file | A relative path or missing write permission | Absolute paths and an appropriate chmod |
| The date command produces a truncated name | Unescaped % in the crontab | Write \% or move the command into a script |
| The server slows down at the job's scheduled time | Overlapping jobs or a heavy job | A lock file, or spread out the schedules |
The job doesn't run at all
Start with the simplest possible test: schedule a job that does nothing but write the time to a file.
* * * * * /bin/date >> /home/user/logs/cron-test.log 2>&1Wait two minutes, then check the file. If it has entries, the cron service is working and the problem is in your command. If it stays empty, the problem runs deeper: the service is stopped, your account is barred from cron, or the crontab file doesn't end with a newline (some older implementations ignore a last line that isn't terminated with Enter).
Then move on to the system logs on a VPS:
grep CRON /var/log/syslog | tail -30 # on Debian and Ubuntu
tail -30 /var/log/cron # on AlmaLinux and Rocky
journalctl -u cron --since "1 hour ago" # via systemdThe log will tell you whether cron even tried to run the job. This separates two completely different possibilities: a time expression that never matched (nothing appears in the log), or a command that failed on execution (the run line appears, followed by an error).
The job runs twice
There are two common causes. The first is that the job is defined in two places: you added it from the hosting panel and then added it again with crontab -e. They are actually the same table, but two different interfaces can fool you. Check crontab -l and compare it with what you see in the panel.
The second cause is the "OR" logic between day of month and day of week that we explained earlier. There is also a sneakier third cause: a long job scheduled at an interval shorter than its run time, so the instances overlap and it looks as if it runs twice. A lock file solves it.
Annoying emails from cron
By default, cron sends all of a job's output to the user's email, even successful output. A job every five minutes that prints a single line means 288 emails a day. You have three options, listed from worst to best:
# 1) silence everything; also hides errors, not recommended
0 3 * * * /home/user/scripts/task.sh >/dev/null 2>&1
# 2) silence only normal output, keep error emails
0 3 * * * /home/user/scripts/task.sh >/dev/null
# 3) best: everything to a log file you can review
0 3 * * * /home/user/scripts/task.sh >> /home/user/logs/task.log 2>&1The difference between the first and second options is subtle and important: 2>&1 means "send the error stream wherever normal output went." Dropping it in the second option means normal output is discarded while errors still reach you by email, which is excellent behavior for critical jobs. If you want to stop cron emails entirely, put a MAILTO="" line at the top of the crontab.
The job runs at the wrong time
The server's clock may differ from your local time, and this is more common than you think: many servers run on UTC by default. A job you scheduled for 3 a.m. will run at 6 a.m. Riyadh time if the server is on UTC.
date # current time on the server
timedatectl # configured time zone (on a VPS)On a VPS you can change the time zone of the whole system, but don't do that on a running server without thinking it through: changing the time zone confuses logs and affects other applications. The simpler alternative is to work out the difference once and write the schedules in server time.
And note a WordPress-specific detail: the time zone you set in WordPress settings only affects how dates are displayed on the site. It has nothing to do with when cron jobs run on the server. The two are completely independent systems.
What should you actually schedule? A plan for a site and a store
Not everything is worth scheduling, and too many jobs consume your resources for no benefit. This matrix helps you choose:
And here is a ready-made practical plan for a content site or a small to medium store:
| Task | Suggested frequency | Cron expression | Note |
|---|---|---|---|
| Run WordPress tasks | Every 10 minutes | */10 * * * * | Replaces wp-cron |
| Database backup | Every 6 hours | 0 */6 * * * | Light and fast |
| Full backup (files and database) | Daily at dawn | 30 2 * * * | Outside peak hours |
| Upload backups to external storage | Daily after the backup | 0 4 * * * | An hour after the backup completes |
| Clean up temporary files | Daily | 0 4 * * * | Protects storage and file count |
| Optimize database tables | Weekly | 0 5 * * 0 | Outside peak days |
| Daily sales report | In the morning | 0 7 * * * | Before the workday starts |
| Abandoned-cart reminders | Every hour | 0 * * * * | Depends on the store's logic |
| Site health checks | Every 5 minutes | */5 * * * * | Very light and fast |
| Comprehensive monthly report | First of the month | 0 9 1 * * | Collects the previous month's data |
Frequently asked questions
Do all shared hosting plans support cron jobs? Most do, but not all. Very cheap plans and some simplified website-builder packages hide the Cron Jobs section entirely to reduce load on the shared server. The quickest way to check: log in to your panel and search for "Cron" in the search box. If nothing comes up, the feature is disabled on your plan. In that case you have two options: upgrade to a plan that supports it, or use an external service that calls a URL on your site at set times. That is an acceptable solution for light tasks, but it depends on a third party.
What is the shortest interval a job can run at? The technical limit of cron itself is one minute, because the service wakes up every minute and knows no smaller unit. There is no standard syntax for seconds at all. In practice, though, most hosting providers on shared hosting impose a higher minimum, five or fifteen minutes, because jobs running every minute across hundreds of accounts overload the server. If you try to schedule below the allowed limit, the panel may refuse to save it, or accept it while the service silently ignores it.
Does disabling wp-cron harm my site?
Not if you immediately replace it with a real server job. In fact, it improves both performance and reliability. The harm happens in only one case: you disable it and forget the replacement. Then all scheduling in WordPress silently stops: no scheduled posts get published, no backups are taken, no emails are sent, and not a single error message appears to warn you. So the safe order is always: create the real cron job, confirm by testing that it actually works, and only then add the disabling line to wp-config.php.
Why do I get an email after every run of the job?
Because that is cron's default behavior: anything the job prints to the screen is emailed to the account owner. Even a simple success message or an HTTP header is enough to generate an email. The cleanest fix is to redirect the output to a log file by adding >> /path/to/log 2>&1 at the end of the command line. If you want to stop the emails entirely, put MAILTO="" at the top of the crontab, or empty the Cron Email field in the panel. Avoid >/dev/null 2>&1 for critical jobs, because it hides errors too.
How do I know the job actually ran?
Use three layers of verification. First, make the job write a line to a log file with the date, time and result, then check the file after the expected run time. Second, on a VPS, check the system log with grep CRON /var/log/syslog to see whether cron even tried to run it. This separates an error in the time syntax from an error in the command. Third, for critical jobs, have the script send a notification only on failure, or update a file that an external monitoring system checks.
Can I run a job every 30 seconds?
Not directly with cron syntax, because the smallest unit it understands is the minute. The well-known trick is to schedule the job every minute and run it twice with a delay: * * * * * /home/user/scripts/task.sh, then a second line * * * * * sleep 30; /home/user/scripts/task.sh. This works, but it is not precise and it keeps an extra sleeping process around the whole time. If you genuinely need intervals in seconds, the right tool is not cron but a persistent background process or a systemd timer with higher precision.
What is the difference between cron and modern automation tools? Cron is a simple time-based trigger: it runs a command at its scheduled time, knows nothing about the command's result, does not handle failure, and does not chain steps together. Modern automation tools add a layer of logic on top: conditions, branching, retries on failure, and connections to external services through APIs. The practical rule: if the task is "run this command at this time," cron is simpler, lighter and more reliable. If it is a chain of conditional steps that passes through multiple systems, you need a full automation tool, and at its core it will still be scheduled by a time-based trigger.
Do cron jobs use my hosting resources? Yes, and many people overlook this. Every run starts a process on the server that consumes CPU, memory and disk I/O, and it counts toward your quota exactly like any visit. A light job every five minutes is negligible, but a full backup compressing gigabytes can push CPU usage to the limit for minutes and slow down the site. So the rule is: schedule heavy jobs outside peak hours, space out large jobs, and monitor your usage for a week after adding any new job.
Sources
Frequently asked questions
Do all shared hosting plans support cron jobs?
Most do, but not all. Very cheap plans and some simplified website-builder packages hide the Cron Jobs section entirely to reduce load on the shared server. The quickest way to check: log in to your panel and search for "Cron" in the search box. If nothing comes up, the feature is disabled on your plan. In that case you have two options: upgrade to a plan that supports it, or use an external service that calls a URL on your site at set times. That is an acceptable solution for light tasks, but it depends on a third party.
What is the shortest interval a job can run at?
The technical limit of cron itself is one minute, because the service wakes up every minute and knows no smaller unit. There is no standard syntax for seconds at all. In practice, though, most hosting providers on shared hosting impose a higher minimum, five or fifteen minutes, because jobs running every minute across hundreds of accounts overload the server. If you try to schedule below the allowed limit, the panel may refuse to save it, or accept it while the service silently ignores it.
Does disabling wp-cron harm my site?
Not if you immediately replace it with a real server job. In fact, it improves both performance and reliability. The harm happens in only one case: you disable it and forget the replacement. Then all scheduling in WordPress silently stops: no scheduled posts get published, no backups are taken, no emails are sent, and not a single error message appears to warn you. So the safe order is always: create the real cron job, confirm by testing that it actually works, and only then add the disabling line to wp-config.php.
Why do I get an email after every run of the job?
Because that is cron's default behavior: anything the job prints to the screen is emailed to the account owner. Even a simple success message or an HTTP header is enough to generate an email. The cleanest fix is to redirect the output to a log file by adding >> /path/to/log 2>&1 at the end of the command line. If you want to stop the emails entirely, put MAILTO="" at the top of the crontab, or empty the Cron Email field in the panel. Avoid >/dev/null 2>&1 for critical jobs, because it hides errors too.
How do I know the job actually ran?
Use three layers of verification. First, make the job write a line to a log file with the date, time and result, then check the file after the expected run time. Second, on a VPS, check the system log with grep CRON /var/log/syslog to see whether cron even tried to run it. This separates an error in the time syntax from an error in the command. Third, for critical jobs, have the script send a notification only on failure, or update a file that an external monitoring system checks.
Can I run a job every 30 seconds?
Not directly with cron syntax, because the smallest unit it understands is the minute. The well-known trick is to schedule the job every minute and run it twice with a delay: /home/user/scripts/task.sh, then a second line sleep 30; /home/user/scripts/task.sh. This works, but it is not precise and it keeps an extra sleeping process around the whole time. If you genuinely need intervals in seconds, the right tool is not cron but a persistent background process or a systemd timer with higher precision.
What is the difference between cron and modern automation tools?
Cron is a simple time-based trigger: it runs a command at its scheduled time, knows nothing about the command's result, does not handle failure, and does not chain steps together. Modern automation tools add a layer of logic on top: conditions, branching, retries on failure, and connections to external services through APIs. The practical rule: if the task is "run this command at this time," cron is simpler, lighter and more reliable. If it is a chain of conditional steps that passes through multiple systems, you need a full automation tool, and at its core it will still be scheduled by a time-based trigger.
Do cron jobs use my hosting resources?
Yes, and many people overlook this. Every run starts a process on the server that consumes CPU, memory and disk I/O, and it counts toward your quota exactly like any visit. A light job every five minutes is negligible, but a full backup compressing gigabytes can push CPU usage to the limit for minutes and slow down the site. So the rule is: schedule heavy jobs outside peak hours, space out large jobs, and monitor your usage for a week after adding any new job.