Development and databases
Create and run cron jobs in cPanel
A cron job runs a command at the frequency you set. It is used to schedule actions such as processing a queue, generating a report or running an application's maintenance.
Although they can be managed from the terminal (the crontab command), cPanel's Cron Jobs section makes setting them up easy through a simple interface.
Notification email
This is the address to which cron sends the standard output and any errors the command produces. If the job produces no output, you won't receive a message confirming each run.

Add new jobs
In cPanel > Cron Jobs, use Add New Cron Job. Choose a common frequency or fill in minute, hour, day of the month, month and weekday. Then enter the command and save.

In the command we set what we want to run. For example, if we have a cron.php file in public_html that carries out maintenance tasks, we should enter:
cd /home/usuario_cpanel/public_html && /opt/alt/php83/usr/bin/php cron.php >> /home/usuario_cpanel/cron.php.log 2>&1
The example uses PHP 8.3: check that this version exists and is compatible. Always use the full PHP path for your application: /usr/local/bin/php or plain php may be a different version, with different extensions. cd sets the working directory for scripts that use relative paths; && stops them running from another folder if the directory change fails. The example saves the output to a log so you don't lose errors. Check and rotate that file. If you want neither a log nor emails, end the command with >/dev/null 2>&1: the output is discarded. This is useful for jobs that run every few minutes, which would fill the mailbox with notifications, but it also hides any failure of the job.
Run a URL from cron
When an application provides a task URL, you can request it with curl:
curl --fail --silent --show-error --max-time 300 https://yourdomain.com/ruta-de-cron
During the first tests, keep the diagnostic output and check the job's result in the application. The email contains the output, not necessarily the exit code. Once you have confirmed it works, you can save it to a private log. Create the destination folder first with the right permissions:
curl --fail --silent --show-error --max-time 300 https://yourdomain.com/ruta-de-cron >> /home/usuario_cpanel/logs/cron-url.log 2>&1
It is better to run the application's PHP or CLI command directly when one exists, because it avoids DNS, SSL and a full web request. Don't include passwords or permanent tokens in a URL that may end up stored in histories and logs.
Choose an interval longer than the maximum run time. If a call takes five minutes and you schedule another one every minute, the jobs can overlap and exhaust processes. The application itself should implement a lock when it doesn't support simultaneous runs.
Current cron jobs
In Current Cron Jobs we have a list of the cron jobs added, so we can edit or delete them as needed.

Check the schedule
| Frequency | Minute | Hour | Day of the month | Month | Weekday |
|---|---|---|---|---|---|
| Every 15 minutes | */15 |
* |
* |
* |
* |
| Every day at 03:10 | 10 |
3 |
* |
* |
* |
| Every Monday at 03:10 | 10 |
3 |
* |
* |
1 |
These times follow the server's cron environment; confirm its time zone before scheduling an action tied to a local time. In cPanel, fill in these fields separately: don't add the five fields to the Command box.
After saving, check the next run through its log or the expected result. A successful manual test doesn't prove that cron has the same environment: it doesn't usually load .bashrc, your terminal's variables or NVM. Use absolute paths and explicitly set up whatever the script needs.
Avoid simultaneous runs
If the command runs in the foreground and flock is available, you can hold a lock for its whole run:
/usr/bin/flock -n /home/usuario_cpanel/tarea.lock /opt/alt/php83/usr/bin/php /home/usuario_cpanel/apps/mi-proyecto/tarea.php
Check the paths and that the application doesn't depend on another working directory. The lock is released when the command finishes; it doesn't cover jobs the command launches in the background or remote processes that carry on after an HTTP call. If it can't get the lock, -n skips that run: check that this behaviour suits your job.
Deleting a cron entry prevents future runs, but doesn't stop one that is already running. If the job takes payments, sends messages or changes data, check its status before repeating it after a timeout.
Queue workers: cron or persistent processes
A queue worker launched from cron has to finish when there is no work left and must not overlap with the next minute's one. For example, for Laravel, every minute:
cd /home/usuario_cpanel/apps/mi-proyecto && /usr/bin/flock -n /home/usuario_cpanel/.cola-mi-proyecto.lock /opt/alt/php84/usr/bin/php artisan queue:work --stop-when-empty --max-time=300
It processes what is pending and finishes; if the previous one is still working, flock -n skips that run. Jobs wait at most one minute. In Laravel you can also launch it from the scheduler, as we explain in Install Laravel.
Don't use cron to leave a worker running with & or nohup: nobody watches it, so if it crashes it doesn't come back, and without a lock another one is added every minute.
On the Avanza, Max and Elastic plans, persistent processes keep a queue worker, Horizon or your own command running at all times, and restart it if it crashes. If you use them, you will see a line in your cron jobs ending in # hostsuar-procesos: it is the watchdog that checks them every minute. Don't edit or delete it; it is managed from Tools > Processes.
A line with schedule:run ending in # hostsuar-deploy- and a number is the scheduler of a Laravel application that Deploy+ scheduled when publishing it. That one is yours: you can change or delete it like any other.
You may also find useful
- Delete old emails automatically in cPanel Delete emails older than X days every day from one account, from every account on a domain or from t...
- Persistent processes: queue workers, Horizon and always-on commands Keep Laravel queue workers, Horizon, a persistent Redis or your own command running on the Avanza, M...
- Apache handlers Set from cPanel which Apache handler should process a given extension, and learn why this option cal...
- Available binaries and tools - FFmpeg, Tesseract, ImageMagick, cURL and more See which binaries are available for video, images, PDF, OCR, networking, DNS, FTP and SFTP, version...
Something wrong or out of date? Tell us and we will review it.