Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I am doing some exercsises in my book but I don't know if I did them right since I don't know how to test them can someone check them ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    1

    Need Help with Cron

    Hi

    I am doing some exercsises in my book but I don't know if I did them right since I don't know how to test them can someone check them over?

    Write the lines that you coulde use in your crontab to schedule the /bin/sample command to run:

    1.Every Friday at 1:30am

    30 01 * * 6 /bin/sample

    2. At 4:30pm on May 15th only

    30 16 15 5 */bin/sample

    3. at 4:00pm and 4:30pm on the first Sunday of every month
    0,30 16 * 0 /bin/sample


    4. every 10mins from 9:00am to 5:00pm on Monday
    */10 09-17 * * 1 /bin/sample
    5. at 8:15 am and 6:30 pm Monday to friday.
    15,30 08,18 * * 0-6 /bin/sample



    Also I found this example from a site

    If you wanted to run a command every day at a certain time for the first week of the month you would enter in 1-7 for the day field. An example of this type of entry would be:

    15,30 */2 1-7 * * joey /usr/bin/somecommand >> /dev/null 2>&1

    This would run somecommand every 2 hours at the 15's and 30's (2:15, 2:30, 4:15, 4:30 etc) for the first 7 days of the month.

    but I don't see how this one works since I don't get how it only knows how to do it the first 1-7days of the month.


    I choose suse section since I am using suse and was not sure if it changes depending on linux version.

    If this is run please put it where it should be.

  2. #2
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5
    When I learned cron jobs I just changed the time and date settings on the machine to the desired test times to see if the job was running properly.

    I also used webmin to schedule them, if you're allowed to use webmin I would suggest it because those questions can be answered in a couple of clicks.

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,281
    Because the field that the '1-7' is in is the day field and the month field is every month '*'.

    Each crontab command line is comprised of six positional fields specifying the time , date and shell script or command to be run. The format of the crontab command line is described as follows:

    Field
    Minute
    Hour
    Day of Month
    Month
    Day of Week
    Command

    Valid values
    0-59
    0-23
    1-31
    1-12
    0-7
    Command path/command

    The day-of-week field accepts either 0 or 7 as a value for Sunday. Any of the time/date fields can also contain an asterisk (*) indicating the entire range of values. Additionally, month and day-of-week fields can contain name (first 3 letters of month or day) values as indicated below.

    Field
    Valid Entries (case insensitive)

    Days of the week
    sun, mon, tue, wed, thu, fri, sat

    SUN, MON, TUE, WED, THU, FRI, SAT

    Months of year
    jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec

    JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC

    When numbers are used, you can specify a range of values separated by a hyphen or a list of values separated by commas. In other words specifying 2-5 in the hour field means 2AM, 3AM, 4AM and 5AM, while specifying 2,5 means only 2AM and 5AM.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

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