LochStudios  /  Help Centre  /  cPanel  /  Set up a cron job

Set up a cron job

Schedule automated tasks to run at specific times using cron jobs in cPanel.

Updated

Cron jobs allow you to run scripts or commands automatically at regular intervals—for example, backing up your database, generating reports, or cleaning up temporary files.

Prerequisites

  • Access to your cPanel control panel
  • The command or script file path you want to run (e.g., /home/username/public_html/backup.php)
  • A basic understanding of cron schedule syntax (or use cPanel's preset options)

Steps

### 1. Log in to cPanel
Open your cPanel and navigate to AdvancedCron Jobs.

### 2. Add a new cron job
In the Add New Cron Job section, fill in the following fields:

- Common Settings: Select a preset interval (e.g., "Once per hour", "Once per day") or choose "Custom" for a specific schedule.
- Command: Enter the full command to run. For a PHP script, use:
```
/usr/bin/php /home/username/public_html/script.php
```
Replace username with your cPanel account username and adjust the path to your script.

### 3. Set the schedule (if using Custom)
If you selected Custom, you'll see five fields for the cron expression:
- Minute (0–59): When in the hour
- Hour (0–23): Which hour (24-hour format)
- Day (1–31): Which day of the month
- Month (1–12): Which month
- Weekday (0–6): Which day of the week (0 = Sunday, 6 = Saturday)

Use * to mean "every" value. For example:
- 0 2 * * * runs at 2:00 AM every day
- */15 * * * * runs every 15 minutes
- 0 9 * * 1 runs at 9:00 AM every Monday

### 4. Save the cron job
Click Add New Cron Job. Your job is now scheduled.

Managing your cron jobs

### View current jobs
Scroll to the Current Cron Jobs section to see all active jobs.

### Edit a job
Click Edit next to any job to change the schedule or command, then click Update Cron Job.

### Remove a job
Click Remove next to the job to delete it.

Tips & troubleshooting

- Verify the script path: Use the full absolute path (starting with /), not a relative path.
- Check your email: If a cron job produces output, cPanel can email it to you. Go to Cron Email to set your address.
- Test before scheduling: Run your command manually in SSH or your browser to ensure it works.
- Monitor execution: If your job isn't running, check the cron error logs in your hosting provider's control panel.
- For web-based scripts: Use a full URL if your cron command includes wget or curl:
```
wget -O /dev/null http://yourdomain.com/task.php
```


Was this article helpful?

← Back to cPanel