Cron jobs let you run commands or scripts automatically on a schedule. They are useful for tasks like clearing caches, sending emails, running backups, or updating data.
What is a cron job?
A cron job is a scheduled command that runs at specific intervals. Each job is defined by a schedule (using five time fields) and a command to execute. The five time fields are: minute, hour, day of month, month, and day of week. Use* to mean "every" value.
Creating a cron job
- Go to the Cron Jobs section of your web hosting server
- Click Add Cron Job
- Fill in the schedule fields:
- Minute (0-59)
- Hour (0-23)
- Day of Month (1-31)
- Month (1-12)
- Day of Week (0-6, where 0 = Sunday)
- Enter the Command to run (e.g.,
php /home/user/domains/yourdomain.com/public_html/artisan schedule:run) - Click Add
Common cron schedules
| Schedule | Minute | Hour | Day | Month | Weekday |
|---|---|---|---|---|---|
| Every minute | `*` | `*` | `*` | `*` | `*` |
| Every 5 minutes | `*/5` | `*` | `*` | `*` | `*` |
| Every hour | `0` | `*` | `*` | `*` | `*` |
| Every day at midnight | `0` | `0` | `*` | `*` | `*` |
| Every Monday at 3 AM | `0` | `3` | `*` | `*` | `1` |
| First day of month | `0` | `0` | `1` | `*` | `*` |
Test First
Run your command manually via SSH or the file manager terminal before scheduling it. This helps catch errors before the cron job runs unattended.
Deleting a cron job
- Go to the Cron Jobs section
- Find the job you want to remove
- Click Delete and confirm
Be Careful
Cron jobs run with your hosting account's permissions. Avoid scheduling resource-intensive tasks too frequently, as this can affect your hosting performance.
CanerAkar