Find the answer to your Linux question:
Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By mace
I am having a bit of trouble and thought I come here to make sure I am correct. I want to run a command at 1:59 on Sunday once a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141

    crontab help


    I am having a bit of trouble and thought I come here to make sure I am correct.

    I want to run a command at 1:59 on Sunday once a month every month. Here is my crontab entry:

    59 1 * 1-12 0

    Is it correct?

    Thanks in advance
    mace

  2. #2
    Just Joined!
    Join Date
    Feb 2012
    Posts
    7
    There is a similar example in man 5 crontab

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    54
    Quote Originally Posted by mace View Post
    I am having a bit of trouble and thought I come here to make sure I am correct.

    I want to run a command at 1:59 on Sunday once a month every month. Here is my crontab entry:

    59 1 * 1-12 0

    Is it correct?

    Thanks in advance
    mace
    Sorry, but what you have will execute every Sunday. What you want might be:

    59 1 * * 0 [ $(date +\%d) -lt 8] && /your/script

    The date +%d gives you number of current day. The script only executes if today's day is < 8, which means you get what you asked for above. An alternative is to include similar code at the top of your script, which terminates execution is today if not the 1st through the 7th.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    Toad...thanks for the reply. The more I looked at it the more I knew i was wrong.
    Also thanks for the code
    mace
    Toadbrooks likes this.

  6. #5
    Just Joined!
    Join Date
    Jan 2013
    Posts
    2
    There is a cron simulator where you can try out these examples and any other set of timing parameters at the CronBuddy website.

  7. #6
    Just Joined!
    Join Date
    Jan 2013
    Posts
    2
    Quote Originally Posted by mlbx View Post
    There is a cron simulator where you can try out these examples and any other set of timing parameters at the CronBuddy website.
    This crontab sandbox has moved to the 'dataphyx' website.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •