Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a Cron job daily from 6 am to 11:30 pm [closed]

Could you help me please to run my cron job daily from 6 am to 11:30 pm in the following format

          • command path

Thanks

like image 806
Samiul Avatar asked Dec 07 '12 07:12

Samiul


1 Answers

cron can start jobs easily enough, but if you need to run something from 6am to 11.30pm, you'll need to issue a start command at 6am, and a stop command at 11.30pm.

something like this:

## start the job (6am)
  0  6 * * * /usr/bin/start-my-job

## stop the job (11.30pm)
 30 23 * * * /usr/bin/stop-my-job

edit: i think i see what you're asking for now. try this:

## every three minutes between 6am and 11.30pm
    */3  6-22 * * * my-command
 0-30/3    23 * * * my-command

edit: okay, if you want 6pm until midday the following day, you need:

## every three minutes between midnight and midday
  */3   0-11  * * * my-command
## every three minutes between 6pm and midnight
  */3  18-23  * * * my-command
like image 76
simon Avatar answered Sep 27 '22 16:09

simon