Skip to content
Deploying apps5 min read

Set up cron jobs in cPanel

Short answer

In cPanel open Advanced › Cron Jobs, pick a schedule (five fields: minute, hour, day of month, month, weekday) and enter a command that uses full paths, for example `/usr/local/bin/php /home/USER/public_html/cron.php >/dev/null 2>&1`. Schedules run in the server's time zone, not yours.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. The schedule syntax
  2. Prerequisites
  3. Step by step
  4. Troubleshooting
  5. On ArabyHost

A cron job is a command the server runs on a schedule: sending queued emails, cleaning a cache folder, running WordPress or Laravel scheduled tasks, or restarting a bot if it stopped. cPanel has a page for it, so you don’t need to edit a crontab by hand. Almost every problem comes down to two things: the schedule fields and the paths in the command.

The schedule syntax

Five fields, separated by spaces, then the command:

┌──────── minute (0-59)
│ ┌────── hour (0-23)
│ │ ┌──── day of month (1-31)
│ │ │ ┌── month (1-12)
│ │ │ │ ┌ weekday (0-6, Sunday = 0)
│ │ │ │ │
* * * * *  command
Schedule Meaning
*/5 * * * * Every 5 minutes
0 * * * * At the start of every hour
0 3 * * * Every day at 03:00
30 2 * * 1 Every Monday at 02:30
0 0 1 * * On the 1st of every month at midnight
0 9-17 * * 0-4 Hourly from 09:00 to 17:00, Sunday to Thursday

* means every value, , separates a list (0,30), - gives a range (1-5), and / sets a step (*/10). The cron generator builds and explains expressions for you.

Prerequisites

  • A hosting account with cPanel.
  • The full path of the script you want to run, for example /home/USER/public_html/cron.php.
  • Optionally SSH (AI/Developer plans) to test the command by hand first.

Step by step

1. Open the Cron Jobs page

In cPanel open Advanced › Cron Jobs. At the top, Cron Email sets where job output is sent. Enter an address while you’re testing, then silence the jobs once they work.

2. Add the job

Under Add New Cron Job, either choose a preset from Common Settings (for example Once Per Five Minutes) or fill in the Minute, Hour, Day, Month and Weekday fields. Type the command in Command and click Add New Cron Job. The job appears under Current Cron Jobs, where you can edit or delete it.

3. Use full paths

Cron runs with a minimal environment: a short PATH, your home folder as the working directory, and none of your shell settings. So spell out every path:

# PHP script
/usr/local/bin/php /home/USER/public_html/cron.php

# Python script in a Setup Python App virtualenv
/home/USER/virtualenv/myapp/3.12/bin/python /home/USER/myapp/task.py

# Calling a URL
/usr/bin/curl -fsS https://example.com/cron/run >/dev/null

If the script reads relative files, cd first: cd /home/USER/app && /usr/local/bin/php artisan schedule:run. Over SSH, which php and php -v show the PHP binary and version your account uses.

4. Handle the output

# Discard everything (no emails)
/usr/local/bin/php /home/USER/public_html/cron.php >/dev/null 2>&1

# Keep a log (create the logs folder first)
/usr/local/bin/php /home/USER/public_html/cron.php >> /home/USER/logs/cron.log 2>&1

> redirects normal output and 2>&1 sends errors to the same place. A log is far more useful than silence when a job misbehaves.

5. Check the server’s time zone

Schedules follow the server clock. To see it without SSH, add a temporary job that runs every minute:

* * * * * date >> /home/USER/cron-time.txt

Open the file in File Manager after a couple of minutes, compare it with your local time, then delete the job and the file.

6. Ready-made examples

WordPress real cron. Add define('DISABLE_WP_CRON', true); to wp-config.php, then:

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

Laravel scheduler (see deploying Laravel):

* * * * * cd /home/USER/laravel && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1

Nightly database dump. Note the \%: an unescaped % in a cron command starts a new line of input.

0 2 * * * /usr/bin/mysqldump --defaults-extra-file=/home/USER/.backup.cnf USER_db | /usr/bin/gzip > /home/USER/backups/db-$(date +\%F).sql.gz

.backup.cnf holds a [client] section with user and password and should be chmod 600.

Keeping a bot or worker alive every 5 minutes: see running a Telegram bot 24/7.

Troubleshooting

  • Works over SSH but not from cron: a relative path, or a command missing from cron’s short PATH. Use absolute paths and cd into the project first.
  • The command is cut off: an unescaped %. Write \%.
  • Permission denied: the script isn’t executable. Run it through its interpreter (/bin/bash script.sh) or chmod 755 it.
  • /bin/bash^M: bad interpreter: the script was saved with Windows line endings. Fix it with sed -i 's/\r$//' script.sh.
  • Runs overlap and pile up: wrap the command with flock, for example /usr/bin/flock -n /home/USER/tmp/job.lock /usr/local/bin/php /home/USER/job.php, so a new run is skipped while the previous one is still working.
  • Nothing happens at all: check the time zone, the email output and the full checklist in cron job not running. For WordPress, see WordPress cron not working.

On ArabyHost

The Cron Jobs page is part of cPanel, which you open with one click from the Araby Panel. On the AI/Developer plans you also get SSH jailed in CageFS, so you can test commands by hand or edit the crontab with crontab -e, and cron is how background workers and bots are kept alive. Cron jobs count toward your account’s resource limits like any other process, so keep frequent jobs light. JetBackup already takes daily backups of your account; a database dump by cron is an extra copy you control, not a replacement.

FAQ

How often can a cron job run?

Cron's smallest step is one minute (`* * * * *`). Run jobs only as often as the work really needs; most tasks are fine every 5 to 15 minutes, while the Laravel scheduler is designed to be called every minute.

Which time zone does cron use in cPanel?

The server's time zone. Add a test job that runs `date` once to see the server's clock, then shift your schedule by the difference from your local time.

Why do I get an email every time the job runs?

cPanel emails any output a job produces to the Cron Email address. Add `>/dev/null 2>&1` to discard it, or redirect it to a log file instead.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.