In short
To set up a cron job in cPanel, open Cron Jobs under the Advanced section, set the schedule with the minute, hour, day, month and weekday fields, and enter the command using full paths. For PHP scripts, use /usr/local/bin/php followed by the full path to the file; to call a URL, use wget or curl. To stop unwanted notification emails, add >/dev/null 2>&1 to the end of the command.
In this guide
To set up a cron job in cPanel, open Advanced > Cron Jobs, choose a schedule and enter the command to run using full file paths. The tricky part is not the syntax but the command itself: cron does not see the environment of your terminal, so relative paths and a missing PHP path are the most common errors. In this guide you will find the scheduling rules, ready-to-use example commands and permanent fixes for common errors.
What is a cron job?
Cron is the scheduler service on Linux servers that runs commands automatically at set times. Each line it runs is called a cron job (a scheduled task). Typical uses on websites include:
- Sending newsletter or notification emails at a set time
- Cleaning up temporary files, old sessions and logs
- Updating exchange rates, stock levels or product prices
- Taking database backups
- Reliably triggering the Laravel scheduler or WordPress scheduled tasks
Cron schedule syntax
Each cron line consists of five time fields followed by the command:
* * * * * command
│ │ │ │ │
│ │ │ │ └── Day of week (0-7, 0 and 7 = Sunday)
│ │ │ └──── Month (1-12)
│ │ └────── Day of month (1-31)
│ └──────── Hour (0-23)
└────────── Minute (0-59)Special characters you can use:
*every value (every minute, every hour...),list:0,30minute 0 and minute 30 of every hour-range:1-5Monday through Friday/step:*/15every 15 minutes
| Schedule | Meaning |
|---|---|
*/5 * * * * | Every 5 minutes |
0 * * * * | At the top of every hour |
30 3 * * * | Every day at 03:30 |
0 9 * * 1-5 | Every weekday at 09:00 |
0 0 1 * * | At midnight on the 1st of every month |
0 2 * * 0 | Every Sunday at 02:00 |
Times follow the server's time zone. If it matters that the task runs at an exact local time (for example, Türkiye time), check the server time with a test job (see the example below).
Setting up a cron job in cPanel step by step
- Log in to cPanel and click the Cron Jobs icon in the Advanced section.
- In the Cron Email field, you will see the address that notifications are sent to when a job produces output. If you do not want output emails, you can clear this field and update it, or silence the output in the command itself.
- Under Add New Cron Job, pick a preset schedule from the Common Settings list (e.g. “Once Per Hour”) or fill in the five fields manually.
- In the Command field, enter the command to run using full paths.
- Click Add New Cron Job. The job appears in the Current Cron Jobs list below, where you can edit or delete it.
The easiest way to find full paths is the Terminal. Your home directory is usually in the form /home/kullaniciadi (your username). If you are new to the Terminal, see our cPanel SSH and Terminal guide.
Example cron commands
Running a PHP script
/usr/local/bin/php /home/kullaniciadi/public_html/cron/gorev.php >/dev/null 2>&1On cPanel servers, /usr/local/bin/php calls the command-line PHP. To run with a specific PHP version, use the EasyApache path; you can list the versions installed on the server in the Terminal with ls /opt/cpanel/:
/opt/cpanel/ea-php83/root/usr/bin/php /home/kullaniciadi/public_html/cron/gorev.phpIf the script opens files relative to its own folder
Cron runs the command from your home directory. If the script uses relative paths such as include 'config.php';, change into the folder first:
cd /home/kullaniciadi/public_html/cron && /usr/local/bin/php gorev.php >/dev/null 2>&1Calling a URL (wget or curl)
Some applications expect the cron task to hit a web address. In that case:
wget -q -O /dev/null "https://alanadiniz.com/cron.php?key=GIZLIANAHTAR"
# or
curl -s -o /dev/null "https://alanadiniz.com/cron.php?key=GIZLIANAHTAR"Remember to put the URL in quotes; if an address containing & is written without quotes, the shell splits the command. When possible, prefer the direct PHP command over a URL: it is not subject to web server timeout limits and cannot be triggered from outside.
Laravel scheduler
In Laravel, a single cron line calls the scheduler every minute, and the task schedules are defined in code:
* * * * * cd /home/kullaniciadi/laravel && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1We explain how to keep queue workers running on shared hosting in our Laravel queue and scheduler guide.
WordPress: a real cron instead of WP-Cron
After adding define('DISABLE_WP_CRON', true); to wp-config.php, run this job every 5 or 15 minutes:
cd /home/kullaniciadi/public_html && /usr/local/bin/php wp-cron.php >/dev/null 2>&1You can find out why this is needed in our guide to disabling WP-Cron.
Daily database backup
An example that takes a compressed backup of the database every night at 03:00. Note that the % signs in the date format are escaped:
0 3 * * * mysqldump --defaults-extra-file=/home/kullaniciadi/.my.cnf kullaniciadi_veritabani | gzip > /home/kullaniciadi/yedekler/db-$(date +\%F).sql.gzInstead of typing the password on the command line, keep it in a .my.cnf file with 600 permissions:
[client]
user=kullaniciadi_dbuser
password=GUCLU_PAROLAKeep the backup folder outside public_html and add a second job that deletes old files; otherwise your disk quota will fill up:
30 3 * * * find /home/kullaniciadi/yedekler -name "db-*.sql.gz" -mtime +7 -deleteManaging crontab from the Terminal
If you have SSH access, you can also edit the crontab directly instead of using the cPanel interface. Both methods show the same list:
crontab -l # lists current jobs
crontab -e # opens jobs in an editorTurning off cron output emails
If a job prints anything to the screen, cron sends that output to the Cron Email address. A job that runs every minute can flood your inbox and use up your account's hourly email sending limit. You have three options:
- Silence everything: Add
>/dev/null 2>&1to the end of the command. The first part redirects normal output, and2>&1sends error output to the same place. - Get errors only: Use just
>/dev/null; normal output is discarded, and you get an email only if there is an error. - Write to a log file: This is the most useful option while debugging.
/usr/local/bin/php /home/kullaniciadi/public_html/cron/gorev.php >> /home/kullaniciadi/logs/cron-gorev.log 2>&1To keep the log file from growing forever, remove this redirect when you are done or clear the file regularly.
Common mistakes and how to fix them
- Using relative paths:
php gorev.phpdoes not work in cron because the working directory is your home directory. Always use full paths orcdinto the folder first. - Wrong PHP: Your site's PHP version and the command-line PHP may differ. If the script needs newer version features, specify the
/opt/cpanel/ea-phpXX/path explicitly. - Percent sign: In a crontab line,
%means a new line. In expressions likedate +%Y-%m-%d, write every%as\%. - Limited environment variables: Cron does not load the PATH and variables from your terminal. Use full paths for commands like
composerandnodetoo; you can find the path withwhich node. - Overlapping runs: If a long-running job has not finished before the next trigger, two copies run at the same time. Prevent this with
flock:*/5 * * * * flock -n /home/kullaniciadi/gorev.lock /usr/local/bin/php /home/kullaniciadi/public_html/cron/gorev.php >/dev/null 2>&1 - Windows line endings: CRLF line endings in
.shscripts written on Windows and uploaded cause a “bad interpreter” error. Save the file with LF line endings. - Running too often: Running a heavy job every minute strains your account's CPU limit and slows down the site. Choose the interval based on what you actually need.
How often should each job run?
When choosing an interval, ask “how much delay is acceptable?” rather than “how often can it run?” For work users are waiting on, such as queues and sending email, 1-5 minutes is usually enough; for cache warming and stock syncing, 15-60 minutes; and for backups and log cleanup, once a day. Scheduling heavy jobs for the night hours when visitor traffic is lowest means a smoother site on the same plan.
Testing that a cron job runs
- Run the command manually in the Terminal first. A command that does not work in the Terminal will not work in cron either.
- Temporarily add a test job that runs every minute:
* * * * * date >> /home/kullaniciadi/cron-test.txt - A few minutes later, open the file in File Manager. If lines are being added, cron is working; the time written also shows the server's time zone.
- When you are done testing, delete the job and the file.
Next step: hosting where cron is easy to use
For simple sites, managing cron takes just minutes in cPanel's Cron Jobs screen; our cPanel web hosting plans run scheduled tasks like these comfortably with LiteSpeed web server and NVMe storage. If your project uses Laravel, Composer or Git, take a look at our Laravel hosting plans, which offer Terminal / SSH access, PHP version selection and a Node.js and Python app manager; if you are starting with a single project, the SA-DEV-1 developer plan lets you manage the scheduler and deployments from one panel. If your cron command is not working on Sunucu Atlas, you can open a support ticket for help.
Frequently asked questions
How often can a cron job run in cPanel?
Cron syntax supports one minute as the smallest unit, so a job can run at most once a minute. Because running heavy jobs every minute strains the account's CPU limit, it is better to choose intervals such as 5 or 15 minutes based on what you actually need.
How do I stop emails from cron jobs?
Add >/dev/null 2>&1 to the end of the command, or clear the Cron Email field on the Cron Jobs screen. If you want to see errors, redirect the output to a log file.
Why does my command work in the Terminal but not in cron?
Cron runs with a different working directory and limited environment variables. Write out full paths for all files and programs, and if the script uses relative paths, add cd /full/path && to the start of the command.
Which time zone does a cron job use?
It runs on the server's system time zone. To be sure, add a temporary job that writes the output of the date command to a file and check the time in the output.
Should I set up cron with a URL or a PHP command?
Use the direct PHP command whenever possible. It does not hit web server timeouts and the task cannot be triggered from outside; use the URL method only if your software requires it.