do you know crontab?

simple brainteaser. take no more than 30 seconds to think about it:

using standard cron installed on your unix system, how often would this command be run:

*/57 * * * * command

? if you choose to answer in comments, please supply version of cron that your system is using.

5 thoughts on “do you know crontab?”

  1. Hello,

    I using vixie-cron, from Portage (using Gentoo):

    [I] sys-process/vixie-cron
    Available versions: 4.1-r9 4.1-r10 {debug pam selinux}
    Installed versions: 4.1-r10(02:19:38 2007-10-14)(pam -debug -selinux)
    Homepage: ftp://ftp.isc.org/isc/cron/
    Description: Paul Vixie’s cron daemon, a fully featured crond implementation

    */57 * * * * root date >> /root/test_cron.txt

    Generated:

    Wed Apr 16 21:57:02 CEST 2008
    Wed Apr 16 22:00:01 CEST 2008
    Wed Apr 16 22:57:01 CEST 2008
    Wed Apr 16 23:00:01 CEST 2008

    At the begining i thought that it will run this date command only XX:57:00 but now i see it’s also run at each hour.

  2. Every crontab field specifies range, ie.
    5 is 5-5 range
    5-10 is 5-10 range
    * is min-max range (for minutes it’s 0-59)

    /n specifies step within range, like in
    for (i=begin; i<=end; i+=step)

    then */57 means
    for (i=0; idow_star’ and ‘e->dom_star’. yes, it’s bizarre.
    * like many bizarre things, it’s the standard.
    */

  3. Sorry, the comment seems to get broken 🙂 Let’s try again:

    Every crontab field specifies range, ie.
    5 is 5-5 range
    5-10 is 5-10 range
    * is min-max range (for minutes it’s 0-59)

    /n specifies step within range, like in
    for (i=begin; i<=end; i+=step)

    then */57 means
    for (i=0; i<=59; i+=57)

  4. I was also caught out and didn’t see it would run on the hour as well as minute 59. I put it into Cron Sandbox at HxPI and got back…

    Sat 14 Jun 2008 1407 UTC
    Forward Schedule
    Sat 14 Jun 2008 1457
    Sat 14 Jun 2008 1500
    Sat 14 Jun 2008 1557
    Sat 14 Jun 2008 1600
    Sat 14 Jun 2008 1657
    Sat 14 Jun 2008 1700

Comments are closed.