Search code examples
cron

How to set cron job to run every minute between 11 PM to 12AM Midnight


I am setting a Cron Job to run every minute between 10 PM to 11 PM as below and its working fine.

*/1  22-23  *   *   *

But when I want to set up it between 11PM to 12AM (Midnight)as below

*/1 23-00   *   *   *

Its showing error as low limit value no. (i.e 23) should be less than higher limit (i.e 00). I have searched on google (or say stackoverflow :D) but have not find any way to run a cron job between 11PM-12AM.


Solution

  • After doing some research on google I find its answer and it is very easy.

    Just include a particular hour or range (between 0,23) in hour column i.e 2nd columns

    *  22-23,23,0-9   *   *   *
    

    This will run a con job for every minute starting from 10:00 PM to 09:00 AM