I have a cronjob I want to run every 17 minutes and it does, but it also runs on the hour. How do I keep it from running on the hour (example 13:00)?


*/17 * * * * php script.php


Aug 10 16:17:01 CROND[1925]: CMD (php script.php)
Aug 10 16:34:01 CROND[1126]: CMD (php script.php)
Aug 10 16:51:02 CROND[1197]: CMD (php script.php)
Aug 10 17:00:01 CROND[1130]: CMD (php script.php)
  • @Rahul changed my wording to "on the hour" to be more clear – JMC Aug 10 '16 at 17:45

You are asking it to run every multiple of 17 minutes, every hour, which is what it is doing (zero is a multiple of seventeen). If you want it to run only at :17, :34 and :51, try

17,34,51 * * * *    php script.php

If you want it to run every seventeen minutes, you'll need to instead use * * * * * and add the time-checking logic to your command.

  • When you refer to my command, are you talking about script.php or part of the cron command? – JMC Aug 10 '16 at 17:49
  • @JMC, either works in theory. In practice, calculating if now is an even multiple of 17 minutes since arbitrary startpoint would be much uglier on the cron command line then hidden in a function in your script. – user4556274 Aug 10 '16 at 17:51
  • 2
    It's not that bad in shell (e.g., in crontab); something like [ $(expr $(date +%s) / 60 % 17) -eq 0 ] && job should do it. You can change the 0 to 0…16 to configure which minute its executed (0 would be at the epoch, 1 would be 1 minute later, etc., and every 17 minutes thereafter) – derobert Aug 10 '16 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.