How to Set Up Cron Jobs
Last Updated: March 2026
3 min read
How to Set Up Cron Jobs
Cron jobs allow you to schedule commands or scripts to run automatically at specified intervals on your hosting server. They’re commonly used for tasks like sending scheduled emails, running backups, cleaning up temporary files, and updating database records.
Setting Up a Cron Job in cPanel
- Log into cPanel.
- Navigate to Advanced > Cron Jobs.
- Under Cron Email, optionally set an email address to receive output from cron job executions.
- Under Add New Cron Job, configure the schedule:
- Common Settings: Select a preset schedule from the dropdown (e.g., “Once Per Hour”, “Once Per Day”).
- Custom Schedule: Set individual fields for Minute, Hour, Day, Month, and Weekday.
- In the Command field, enter the command to execute.
- Click Add New Cron Job.
Understanding Cron Schedule Syntax
The schedule follows this format:
* * * * *
â â â â â
â â â â âââ Day of Week (0-7, Sun=0 or 7)
â â â âââââ Month (1-12)
â â âââââââ Day of Month (1-31)
â âââââââââ Hour (0-23)
âââââââââââ Minute (0-59)
Common Schedule Examples
| Schedule | Cron Expression | Description |
|---|---|---|
| Every minute | * * * * * | Runs every minute |
| Every 5 minutes | */5 * * * * | Runs every 5 minutes |
| Every hour | 0 * * * * | Runs at the top of every hour |
| Every day at midnight | 0 0 * * * | Runs once daily at 12:00 AM |
| Every Monday at 3 AM | 0 3 * * 1 | Runs weekly on Monday at 3:00 AM |
| First of each month | 0 0 1 * * | Runs on the 1st of every month |
Common Cron Job Commands
Run a PHP script:
/usr/local/bin/php /home/username/public_html/script.php
Run a WordPress cron:
/usr/local/bin/php /home/username/public_html/wp-cron.php
Run a shell script:
/bin/bash /home/username/scripts/backup.sh
Fetch a URL (trigger a web-based script):
/usr/bin/curl -s https://yourdomain.com/cron-task.php > /dev/null 2>&1
Tips and Best Practices
- Suppress output by appending
> /dev/null 2>&1to your command to avoid receiving emails for every execution. - Use full paths to executables (e.g.,
/usr/local/bin/phpinstead of justphp). Find the path withwhich phpvia SSH. - Test your script manually via SSH before scheduling it as a cron job.
- Avoid running jobs too frequently on shared hosting to prevent exceeding resource limits.
- Set the cron email during testing to debug issues, then disable it for production.
Managing Existing Cron Jobs
In cPanel under Cron Jobs > Current Cron Jobs, you can:
- Edit a cron job’s schedule or command
- Delete cron jobs that are no longer needed
Troubleshooting
- Cron not running: Ensure the command path is correct. Test it via SSH first.
- Permission denied: Make sure the script has execute permission (
chmod +x script.sh). - No output: Check the cron email for error messages, or log output to a file.
For help setting up cron jobs, contact 10Corp support.
Tags:
hosting
cron
automation
scheduled-tasks
cpanel