Cron jobs are scheduled tasks that run automatically at specified times on your server. They are used for things like running scripts, sending scheduled emails, or updating plugins.
Accessing Cron Jobs:
-
Log in to cPanel.
-
In the "Advanced" section, click on "Cron Jobs."
Adding a Cron Job:
You will see two sections: "Common Settings" (for beginners) and "Add New Cron Job."
-
Choose a Common Setting (or specify custom):
-
This dropdown lets you select common intervals (e.g., Once Per Hour, Once Per Day). Selecting one will auto-fill the "Minute, Hour, Day, Month, Weekday" fields.
-
-
Enter the Command:
-
This is the actual script or command you want to run.
-
For example, to run a PHP script:
php /home/username/public_html/script.php -
Or to run a WordPress cron:
wget -q -O /dev/null https://yourdomain.com/wp-cron.php?doing_wp_cron
-
-
Click "Add New Cron Job."
Understanding the Timing Syntax:
If you choose "Custom," you need to understand the five timing fields:
-
Minute: (0-59)
-
Hour: (0-23)
-
Day: (1-31)
-
Month: (1-12)
-
Weekday: (0-7) (Sunday is 0 or 7)
Example: To run a command every day at 3:30 AM, you would set:
-
Minute:
30 -
Hour:
3 -
Day:
*(every day) -
Month:
*(every month) -
Weekday:
*(every day of week)