Running a cron job every 2:30 on every day?

user3770138 picture user3770138 · Jun 24, 2014 · Viewed 10.8k times · Source

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?

Answer

dogbane picture dogbane · Jun 24, 2014

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 * * *.