How to Set Up and Manage Cron Jobs in cPanel
A Cron Job is a powerful server tool that allows you to automate repetitive tasks or run specific scripts (like PHP, Python, or shell scripts) automatically at designated intervals, hours, or days. For instance, you can use cron jobs to automate database backups, send out weekly email newsletters, or sync product inventories.
At CeylonServers, you can schedule these automated background tasks easily through your cPanel interface. Follow this step-by-step guide to set them up:
Step 1: Open the Cron Jobs Interface
- Log in to your cPanel dashboard directly.
- Scroll down to the Advanced section or search for "Cron Jobs" in the top search bar.
- Click on the "Cron Jobs" icon.
.png)
Step 2: Configure Cron Email Notifications (Optional)
- Before creating a cron task, you can decide if you want to receive an email log every time the task runs.
- Locate the Cron Email section at the top.
- Enter your professional email address in the field and click "Update Email".
- Pro-Tip: If your script runs every 5 minutes, you will receive a lot of emails. To stop email logs for a specific cron job, you can add
>/dev/null 2>&1to the very end of your script command.
Step 3: Define the Schedule (Add New Cron Job)
Scroll down to the Add New Cron Job section. You need to tell the server exactly when and how often to run your task.
Common Settings: Click this dropdown menu first. It offers pre-configured, easy presets like:
- Once per minute (
* * * * *) - Once per hour (
0 * * * *) - Twice per day (
0 0,12 * * *) - Once per week (
0 0 * * 0)
Selecting a preset will automatically fill in the specific timing fields (Minute, Hour, Day, Month, Weekday) for you. You can adjust these manually if needed.
.png)
Step 4: Enter the Command to Execute
In the "Command" text box, you must provide the exact absolute path to the program interpreter and your script file.
Here are the most common command structures used for hosting setups:
To run a specific PHP file (Recommended setup):
Bash
/usr/local/bin/php
/home/yourusername/public_html/cron.php
(Make sure to replace yourusername with your real cPanel username and adjust the path to your actual file).
To run a standard WordPress internal cron routine:
Bash
/usr/local/bin/php /home/yourusername/public_html/wp-cron.php
>/dev/null 2>&1
Step 5: Save and Activate
- Review your timing settings and command path.
- Click the blue "Add New Cron Job" button.
- A success message will appear, and your automated task is now live and waiting for its scheduled runtime!
How to Manage or Delete Existing Cron Jobs:
- If you need to temporarily stop or modify a background command:
- Scroll down to the very bottom of the page to the Current Cron Jobs table.
Locate your active cron job row.
- Click "Edit" to change the execution frequency or script location.
- Click "Delete" if you want to remove the automated routine completely from the server system.
- Server Performance Warning: To keep our hosting platform stable for everyone, running intensive scripts once per minute is highly discouraged unless strictly necessary. For general scripts, scheduling them to run once per hour or during low-traffic midnight windows is highly recommended.
Need Help Formatting a Command? If your automated script is returning a "File not found" error or if you are unsure about your exact server directory paths, please Open a Support Ticket from your client portal, and our technical systems team will trace the correct script loop path for you!