cron

Run CRON job every day at specific time


Right now I am running my cron job every day at 3.00PM

0    15    *    *    *

But I want to run my cron job twice in a day. 10.30AM and 2.30PM

0    30 10    *    *    *

I believe this command will run at 10.30AM. How should I run it at 2.30PM?


Solution

  • Cron utility is an effective way to schedule a routine background job at a specific time and/or day on an on-going basis.

    Linux Crontab Format

    MIN HOUR DOM MON DOW CMD

    enter image description here

    Example::Scheduling a Job For a Specific Time

    The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM.

    Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.

    30 08 10 06 * /home/yourname/full-backup
    

    In your case, for 2.30PM,

    30 14 * * * YOURCMD
    
    1. 30 – 30th Minute
    2. 14 – 2PM
    3. *– Every day
    4. *– Every month
    5. *– Every day of the week

    To know more about cron, visit this website.