DEV Community

Cover image for */5 does not start five minutes from now
Ameen Usman
Ameen Usman

Posted on

*/5 does not start five minutes from now

*/5 does not mean “five minutes after you save the crontab.” The line */5 * * * * is locked to the clock. It runs at minute 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55 of every hour. Install it at 10:03 and the next run is 10:05, then 10:10. The schedule does not remember when you edited the file.

Build the five fields in the cron expression generator. The page does not install the job. Copy the expression into the crontab on the machine that will run it.

What the step actually lists

*/5 * * * *     # 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55
*/10 * * * *    # 0, 10, 20, 30, 40, 50
*/15 * * * *    # 0, 15, 30, 45
*/30 * * * *    # 0 and 30
Enter fullscreen mode Exit fullscreen mode

Each of those includes minute 0. 5-59/5 * * * * is different: the range starts at 5, so minute 0 is skipped. Use that only when you really want to skip the top of the hour.

From now needs a different tool

To wait five minutes from an arbitrary moment, sleep inside a process, or use a queue’s delay. Cron will still wake up on minutes 0, 5, 10, and the rest. Five-field cron has no seconds field. The daemon starts once when the matching minute begins.

Do not paste a Quartz or EventBridge line into a five-field crontab. Call the program by its absolute path. Cron’s PATH is often short.

Guide: https://kepttools.com/guides/cron-every-5-minutes

Top comments (0)