How a cron expression works
Cron is the scheduler on Linux servers. A schedule has five fields separated by spaces — minute, hour, day of the month, month and day of the week — and the server runs the command whenever all of them match. A * means “every”, so 0 3 * * * means “at minute 0 of hour 3, every day”.
The building blocks
- * — every value: * in the hour field means every hour.
- */15 — every 15th value: */15 in the minute field means every 15 minutes.
- 1-5 — a range: 1-5 in the weekday field means Monday to Friday (0 and 7 are Sunday).
- 1,15 — a list: 1,15 in the day field means the 1st and 15th of the month.
- @daily, @hourly, @weekly — shortcuts many servers accept.
- When both the day-of-month and day-of-week fields are set, cron runs on either one — a classic surprise this tool points out.
Adding a cron job to your hosting
- cPanel: Advanced → Cron Jobs. Choose the common setting or enter the five fields, and paste your command.
- Hostinger hPanel: Advanced → Cron Jobs. Choose Custom and enter the fields, or pick PHP and give the script path.
- A VPS: run crontab -e and add the whole line shown here.
Good to know
- Servers usually run on UTC, not your local time. Check your server’s time zone and adjust the hour.
- Use full paths to programs and files; cron does not load your usual shell settings.
- Very frequent jobs (every minute) can be limited by shared hosting plans; every 5 or 15 minutes is often the minimum.
Frequently asked questions
What is the cron expression for every 5 minutes?
*/5 * * * *
How do I run a cron job every day at midnight?
0 0 * * * — or the shortcut @daily.
How do I run a PHP script with cron?
Use the full path to PHP and the script, such as /usr/bin/php /home/username/public_html/cron.php. Your host’s cron page usually shows the right PHP path.