Skip to content

Running cron job every 12 hours (twice a day)

Covers
Cron

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.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top