How do I create a cronjob in cPanel?

Prev Next

This guide will detail how to create a cron job within cPanel.

Crons are Linux's automated command tool, similar to task scheduler in Windows environments. They run on a schedule that can be configured at will. Commonly, they are used for running automatic updates, clearing files etc.

Note

Cronjobs rely on a script to run, and can be abused if incorrectly created. We recommend this for advanced users familiar with scripting and linux command line operations.

1. Log into the cPanel account you want to run the script
2. In the Advanced section, click Cron Jobs:

  1. (Optional) Set-up Cron Email

    • This will allow you to receive notifications when a cronjob runs

    • If you do not want to receive notifications, simply leave the field blank

  1. Add New Cron Job

    • Under the Add New Cron Job tab, you will have several options

      • Common Settings - Common preset intervals e.g. once per day, once per week etc.

      • Time settings - the time between each cron or the interval with which it will run

      • Command - the command to run at the designated time

        • The file must have the appropriate permissions for custom scripts

In the above example, the script ./myscript.sh will run at 1:30 PM on the 1st and 15th of each month on a Saturday. This can be set to whatever value best suits your needs.

Beneath this window is where you can view all current cronjobs. From here, you can edit or delete crons.

For further information, please refer to the following resources: