Menu

0 */2 * * * is every second hour, starting at midnight
📰

0 */2 * * * is every second hour, starting at midnight

DEV Community: beginners·Ameen Usman·about 3 hours ago
#J4elhnHQ
#devtobeginners#devto#dev#field#hour
Reading 0:00
15s threshold

0 */2 * * * looks short. On a five-field crontab it means minute 0 of every second hour. The hour field steps from 0, so the day runs at 00:00, 02:00, 04:00, 06:00, 08:00, 10:00, 12:00, 14:00, 16:00, 18:00, 20:00, and 22:00. The last fire that day is 22:00, not 23:00.

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

How the step is counted

A step is a range plus /n . In the hour field, * is the full hour range, so */2 walks that range by two, starting at 0. Pin the minute to 0 and you get the top of those hours only.

That is different from every hour:

0 * * * * # every hour, at minute 0 0 */2 * * * # every second hour, at minute 0

Enter fullscreen mode

Exit fullscreen mode

0 * * * * fires 24 times a day. 0 */2 * * * fires 12 times. Neither line has a seconds field.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.