The Line for Every 5 Minutes
*/5 * * * * /usr/local/bin/check-queue.shOpen your crontab with crontab -e, add the line, and save. The job runs at minute 0, 5, 10, and so on up to 55 of every hour. It follows the clock: saving the crontab at 10:03 means the first run is at 10:05, not at 10:08. Creating and editing crontabs is covered in how to create a cron job.
The Five Fields
* * * * * command
| | | | |
| | | | +---- day of week (0-7, Sunday is 0 or 7)
| | | +--------- month (1-12)
| | +-------------- day of month (1-31)
| +------------------- hour (0-23)
+------------------------ minute (0-59)- Asterisk: every value.
- Comma: a list, as in
0,30. - Hyphen: a range, as in
1-5. - Slash: a step, as in
*/5for every fifth value.
Common Schedules
| Fields | Runs |
|---|---|
* * * * * | Every minute |
*/ | Every 5 minutes |
*/ | Every 15 minutes |
0 * * * * | Hourly, on the hour |
30 3 * * * | Daily at 03:30 |
0 9 * * 1- | Weekdays at 09:00 |
0 4 * * 0 | Sundays at 04:00 |
0 0 1 * * | First of the month |
*/ | Every 5 minutes, office hours |
@reboot | Once at boot |
One rule catches many people: when both day of month and day of week are set, the job runs when either one matches. 0 0 1 * 1 runs on the first of the month and on every Monday.
Spread the Load
Every job set to */5 starts at the same second. If several heavy jobs run on one server, shift them with a range plus a step: 2-59/5 runs at minute 2, 7, 12, and so on.
Which Time Zone Cron Uses
Cron reads times in the server's system time zone, not in yours. Check it with timedatectl, and change it as shown in how to change the time zone in Ubuntu. Restarting cron after a change makes sure it uses the new zone: the service is cron on Debian and Ubuntu and crond on AlmaLinux and Rocky Linux. In a zone with daylight saving time, cron treats jobs at a fixed time specially on the change dates: when the clock moves forward, jobs in the skipped hour run right after the change, and when it moves back, they are not run a second time. Jobs with a step such as */5 follow the new clock. Servers kept on UTC avoid the question.
Stop Overlapping Runs with flock
If one run takes longer than 5 minutes, cron starts the next one anyway, and two copies work on the same data. flock prevents this:
*/5 * * * * flock -n /tmp/check-queue.lock /usr/local/bin/check-queue.shflock takes a lock on the file before it starts the script. With -n it gives up at once if a previous run still holds the lock, so that run is skipped. The lock ends when the script exits, even after a crash, so a leftover lock file never blocks later runs. flock is part of util-linux and present on every common distribution.
Write Jobs That Work Under Cron
- Full paths: cron's search path can be shorter than the one in your shell, so write
/usr/bin/php, notphp. - Percent signs: cron treats
%as a line break; escape it as\%, for example indate +\%F. - Output: append
>> /home/deploy/check-queue.log 2>&1to keep messages and errors.
Check That It Ran
journalctl -u cron --since "1 hour ago"
journalctl -u crond --since "1 hour ago"Use the first on Debian and Ubuntu, the second on AlmaLinux and Rocky Linux. Each run appears with the user and the command. To see every job on the server, follow how to list cron jobs. A systemd timer with OnCalendar=*:0/5 is an alternative that logs each run in the journal; see systemd unit files.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations