Need help with a few Crontab entries

Posted on 2009-04-23
Last Modified: 2013-12-16
I need a few crontab entries to run a script :
1. Every hour, on the hour
2. Every hour, 15 mins past the hour
3. Every hour, half past the hour
4. Every 15 mins
5. Every 22 mins
Question by:TotallyMe
    LVL 68

    Expert Comment

    a crontab entry basically takes the format
    minute hour day-of-month month day-of-week command
    (with an asterisk defining all values, from lowest to highest)

    1) 0 * * * * [command]
    2) 15 * * * * [command]
    3) 30 * * * * [command]
    4) 0,15,30,45 * * * * [command]
    5) impossible, as 22 is not evely divisible by 60. Nearest approach
    0,22,44 * * * * [command]
    For 4), there are other notations, but not in all Unixes
    I put an asterisk for the values (day-of-month, month, day-of-week)you didn't mention in your Q.
    LVL 40

    Accepted Solution

    here we are:

    1- 0 * * * * /path/to/script
    2- 0/15 0 * * * /path/to/script
    3- 30 * * * * /path/to/script
    4- same as 2
    5- 0,22,44 * * * *  /path/to/script
    LVL 40

    Expert Comment


    2- 15 0 * * * /path/to/script
    4- 0/15 0 * * * /path/to/script

    LVL 5

    Expert Comment

    LVL 12

    Expert Comment

    5. I've had a similar problem in the past, and used the "at" command to re-schedule a script to run at intervals that are not evenly divisible into 60 minutes (like every 22 minutes). The first thing the script does is re-schedule itself in another 22 minutes. The trick is that current time can't be used to determine the next run time, since the job might be delayed on a busy system.

    I addressed this by including the scheduled time as an argument to the job, and some simple perl code to re-submit itself based upon the value.
    LVL 14

    Expert Comment


    Check the crons from Omar Farid first post above with a simple correction on:

    2/     15 * * * * /path/to/script       this runs every  hour +15 minutes like 1:15, 2:15 , 3:15...etc
    4/     */15 * * * *  /path/to/script    this runs every 15 minutes
    LVL 68

    Expert Comment

    Please remember that the '*/n' syntax is not supported at least in AIX, HPUX, Solaris and most of the remaining commercial Unixes!
    LVL 40

    Expert Comment

    woolmilkporc is correct about the syntax , but since this is under linux zone assumption is made that it is linux platform which supports this format

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now