0

This question already has an answer here:

I need create a cron job running every 2 hours and 5 minutes, is this possible? This doesn't work since is running each 5 minutes :(

user@server$ crontab -l
0,5,10,15,20,25,30,35,40,45,50,55 0,2,4,6,8,10,12,14,16,18,20,22 * * *  date >> /tmp/cron-test01.out
user@server$ cat /tmp/cron-test01.out
Mon Sep 19 10:05:00 GMT 2016
Mon Sep 19 10:10:00 GMT 2016
Mon Sep 19 10:15:00 GMT 2016
Mon Sep 19 10:20:00 GMT 2016
Mon Sep 19 10:25:00 GMT 2016
Mon Sep 19 10:30:00 GMT 2016
user@server$

marked as duplicate by GAD3R, don_crissti, Eric Renouf, sam, roaima Sep 19 '16 at 16:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Do you mean to run the command after every 2:05? Or Every 2:00 and every 0:05? – Centimane Sep 19 '16 at 13:38
  • If you need help with what to input your crontab, try looking at this link: crontab.guru – ryekayo Sep 19 '16 at 13:39
  • Could you run it every 125 minutes? – Robert Fraser Sep 19 '16 at 13:52
  • You don't note which version of Solaris. If you're using v11, you could look into using Periodic and scheduled services with SMF to see if that will better fit your requirements over using cron. blogs.oracle.com/gman/entry/… – sleepyweasel Feb 2 '17 at 23:22
4

cron does not naturally handle this kind of interval. You could try running a job every five minutes and adding a time check within the job to allow it to execute every 125 minutes:

*/5 * * * *    [ $(expr $(date +\%s) / 60 \% 125) -eq 0 ] && date >> /tmp/cron-test01.out
  • I couldn't make it work pastebin.com/xFSwpQnU – Pab Sep 19 '16 at 18:21
  • @PabloAngarano, my response works with bash and Vixie cron running on Linux. I don't have a solaris system to compare, but the same principal should work even if the syntax needs to be changed, for example, it may not be necessary to escape the % symbols. – user4556274 Sep 19 '16 at 19:28
  • I believe the */5 syntax is specific to Vixie cron, hence the reason why this won't work on Solaris. You need to do 0,5,10,15,20,25,30,35,40,45,50,55 instead. Yes, I know: cumbersome. – peterh Oct 6 '16 at 14:33

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