2

I have a cron entry that runs every 30 minutes -

*/30 * * * * /home/myuser/myscripts.sh

How to set this up such that it runs exactly at 30 minute intervals but also exactly at (for example)

3:00 PM, 3:30 PM, 4:00 PM, 4:30 PM and so on.

So I'm not only interested in the 30 minute interval but also the time being close to "round figures" on the clock.

So 3 PM is just an example. I want the job to run at times that are "round figures", like "3:00 PM, 3:30 PM, 4:00 PM" and not "3:15 PM, 3:45 PM, 4:15 PM"

6
  • Your problem specification is confusing....you say that you want it to start specifically at 3PM but then run every 30 minutes? So do you want the job to run just at 30 minute intervals at 00,30 with the start time irrevelent?
    – mdpc
    Commented Apr 29, 2014 at 19:03
  • @mdpc 3PM is just an example. I want the job to run at times that are "round figures", like "3:00 PM, 3:30 PM, 4:00 PM" and not "3:15 PM, 3:45 PM, 4:15 PM".
    – Wes
    Commented Apr 29, 2014 at 19:05
  • 0,30 3-6 * * * /home/myuser/myscripts.sh - it will run at 3:00, 3:30, 4:00. 4:30....6:30
    – user34720
    Commented Apr 29, 2014 at 20:05
  • 1
    That's what */30 does. It doesn't pick a random time and go every 30 minutes from there, it does it on the (half) hour.
    – Kevin
    Commented Apr 29, 2014 at 20:18
  • FYI: If you run man 5 crontab you should get full documentation.
    – derobert
    Commented Apr 29, 2014 at 20:29

1 Answer 1

4

You can specify

0,30 * * * * /home/myuser/myscript.sh

although I was always under the impression this would be the same as */30 * ..... But I have never used anything that had to be on the minute like that, just at a regular interval (*/5 * ....)

3
  • @wes - If you want to run it at 3pm and 4pm you can also add those to the hour column using the same method.
    – slm
    Commented Apr 29, 2014 at 19:05
  • @slm You are right but from the Q, I was under the impression that this was to be for every hour and 3 & 4 PM only as examples.
    – Anthon
    Commented Apr 29, 2014 at 19:07
  • me too, but I was adding that since the OP seemed to not know even this basic thing about cron 8-). Note my comment was directed to him.
    – slm
    Commented Apr 29, 2014 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .