Find the answer to your Linux question:
Results 1 to 8 of 8
Hello I need to create the following cron jobs: job #1: runs Mon,Tue,Wed,Thu,Fri,Sun at 9PM every month except for 15th job#2: runs on 15th of each month at 9PM job ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    4

    CRON jobs


    Hello

    I need to create the following cron jobs:
    job #1: runs Mon,Tue,Wed,Thu,Fri,Sun at 9PM every month except for 15th
    job#2: runs on 15th of each month at 9PM
    job #3: runs every Saturday at 6PM every month


    What is the correct syntax for this kind of scheduled cron jobs?

    Thanks,
    Lena

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    If you go into a terminal and run the command "man 5 crontab", you will get a page of documentation explaining crontab. This includes information on the format of the crontab file.

    Alternatively, you can go to Wikipedia and see the information there:
    http://en.wikipedia.org/wiki/Cron

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    4
    I know how to use documentation.
    I'm asking for help to post exact syntax for this scenario.
    The one I already have doesn't work.

  4. #4
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,733
    Quote Originally Posted by lenag View Post
    I'm asking for help to post exact syntax for this scenario.
    The one I already have doesn't work.
    Hello and welcome!

    If you'll post what you have now, someone might be able to help you figure out why it's not working.
    oz

  5. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    4
    # normal backups w/ cleanup
    10 21 1-14,16-31 * 0,1,2,3,4,5 /export/home/oracle/scripts/rmanscriptinc1 > /export/home/oracle/logs/cronrmaninc1.out 2>&1
    10 18 * * 6 /export/home/oracle/scripts/rmanscriptinc0 > /export/home/oracle/logs/cronrmaninc0.out 2>&1
    # backup entries with cleanup
    #10 18 * * 6 /export/home/oracle/scripts/rmanscriptinc0 > /export/home/oracle/logs/cronrmaninc0.out 2>&1
    10 21 15 * 0,1,2,3,4,5 /export/home/oracle/scripts/rmanscriptinc1_cleanup > /export/home/oracle/logs/cronrmaninc1.out 2>&1

    What happened yesterday is that both scripts rmanscriptinc1 and rmanscriptinc1_cleanup ran even though rmanscriptinc1_cleanup is only scheduled to run once a month on 15th.

    Thanks,
    Lena

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,752
    Google: cron examples

    Code:
    5,10 	0 	10 	* 	1 	 At 12.05,12.10 every Monday & on 10th of every month

  7. #7
    Just Joined!
    Join Date
    May 2010
    Posts
    4
    I don't think it will work in my case.
    In your example you have the same job scheduled, and in my case I need to schedule 2 separate jobs.

  8. #8
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,752
    Q.

    What happened yesterday is that both scripts rmanscriptinc1 and rmanscriptinc1_cleanup ran even though rmanscriptinc1_cleanup is only scheduled to run once a month on 15th.
    A.

    NO, it's not.

    Code:
    5,10 	0 	10 	* 	1 	 At 12.05,12.10 every Monday & on 10th of every month

    Let's read the example AGAIN.
    Code:
    10 21 1-14,16-31 * 0,1,2,3,4,5 /export/home/oracle/scripts/rmanscriptinc1 > /export/home/oracle/logs/cronrmaninc1.out 2>&1
    This is scheduled for dates 1-14, 16-31 AND Sun > Fri - like it says in any CRON example/link/documentation.

Posting Permissions

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