Haruke Sensei
Haruke Sensei

Reputation: 57

How to ignore the minute part in cron?

*/41 * 6-20 ? * * *

so I have this cron expression and I want it to send a command every 41 seconds e.g. if it sends a message at 2:00:00 the next message should be sent at 2:00:41 but it also sends a message at 2:01:00 but I don't want it to send a message at 2:01:00 so how can I fix it?

Upvotes: 0

Views: 84

Answers (1)

jeesj
jeesj

Reputation: 36

You have */41 in the minutes specifier - that means every 41st minutes.

#       .---------------- minute (0 - 59)
#       |       .------------- hour (0 - 23)
#       |       |       .---------- day of month (1 - 31)
#       |       |       |       .------- month (1 - 12) OR jan,feb,mar,apr ...
#       |       |       |       |       .----- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat
#       |       |       |       |       |
#       *       *       *       *       *  

Since cron does not go down to sub-minute resolutions, you will need to find another way(for eg: you can use sleep)

Upvotes: 1

Related Questions