Find the answer to your Linux question:
Results 1 to 6 of 6

Thread: crontab help

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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
    There is a similar example in man 5 crontab

  3. #3
    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
    Toad...thanks for the reply. The more I looked at it the more I knew i was wrong.
    Also thanks for the code
    mace

  6. #5
    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
    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
  •