2

If I creating cronjob to running for every 2:30 the command will run? (It mean, my cron will running after 90 minutes for every hours.)

the command like: 30 */2 * * * /command/xxx => that's right?

Please help?

user3770138
  • 51
  • 1
  • 1
  • 4
  • 2
    possible duplicate of [Running a cron job at 2:30 am every day? How to setup?](http://stackoverflow.com/questions/14710257/running-a-cron-job-at-230-am-every-day-how-to-setup) – devnull Jun 24 '14 at 07:42
  • NO duplicate! Because my command will running every 2:30. It mean, my cron will running after 90 minutes for every hours. – user3770138 Jun 24 '14 at 08:09

2 Answers2

7

Your cron expression 30 */2 * * * will run the command every 2 hours at 30 mins past the hour i.e.00:30, 02:30, 04:30, 06:30 and so on.

If you want to run your command at intervals of two and a half hours i.e. 00:00, 02:30, 05:00, 07:30 and so on, you need to set up two crons:

0 0-20/5 * * * runs at 0 mins past the hour, every 5 hours between 00:00 and 20:00 inclusive i.e. 00:00, 05:00, 10:00, 15:00 and 20:00

30 2-22/5 * * * runs at 30 mins past the hour, every 5 hours between 02:00 and 22:00 inclusive i.e. 02:30, 07:30, 12:30, 17:30 and 22:30

On the other hand, if you want to run your command only once every day at 02:30 use 30 2 * * *.

dogbane
  • 266,786
  • 75
  • 396
  • 414
  • Every two and a half hours, are you sure? Isn't `30 */2 * * *` more like every second hour at 30 minutes? Say, 0:30, 2:30, 4:30 and so on. – scai Jun 24 '14 at 07:50
  • What if you wanted to execute a command every 30 minutes, starting at 2:30 and ending at 5:00? Let's assume that in this 2.5 hour period, this routine 30 minute check needs to be made, but it shouldn't run earlier or later. So 2:30, 3:00, 3:30, 4:00, 4:30, 5:00. How do you express the start and end times as absolutes while making the frequency dynamic (an interval rather than a set time?) – Anthony Aug 29 '16 at 11:30
  • The closest I can think of is `30/30 2-5 * * *` which I believe would be 2:30, 3:00, 3:30, 4:00, 4:30, 5:00, 5:30. Is there a way to only have the 5:00 match, like some sort of `30/30+1 2-4 * * *` where it essentially tells it to run until 4:30 and then one more 30 minute cycle? – Anthony Aug 29 '16 at 11:38
  • we can also define 0 and 30 minute past for every 5 hour => 0,30 0-20/5 * * * – Abhishek Sharma Oct 22 '18 at 07:11
0
sudo crontab -e

and then add this:

30 2 * * * /enter/your/command
Hamid Parchami
  • 7,319
  • 2
  • 18
  • 22