Running cron job every 12 hours (twice a day)

Running cron job every 12 hours (twice a day)

Some of the tasks are required to run twice per day. You can use */12 in hours section to schedule a job to run at 12AM and 12PM daily. Sometimes you need to run crontab at different hours or minutes. In that case, you can define the hours like 09,17 etc.

Scheduing crontab every 12 hours
Scheduing crontab every 12 hours

For example:

0    */12   *    *    *      script.sh

The above script will run at 12 AM (00:00:00) and 12 PM (12:00:00) every day.

As you can see that using */12 executes cron exactly at 12AM and 12PM. But, sometimes you may need to run crontab at different times like 10 AM and 10 PM. In that case, you need to set hours like 10,22. See the below example:

0    10,22   *    *    *      script.sh

You can change hours of your choice like 09,17 to execute cron at 09 AM and 05 PM.

Hope this tutorial helps you with crontab configuration and schedule jobs twice a day.

The post Running cron job every 12 hours (twice a day) appeared first on TecAdmin.

cron crontab General Articles jobs scheduler TecAdmin