+ Reply to Thread
Results 1 to 1 of 1

Thread: Tutorial: Crontab Editing

  1. #1
    Join Date
    Nov 2007
    Posts
    212

    Default Tutorial: Crontab Editing

    Cron is a program that acts as a job scheduler to run different programs or scripts at set times or intervals.

    Its main configuration file, crontab, is a simple text file that contains the table of jobs to run where each line represents a new job to run.

    To edit the crontab, simply type
    Code:
    crontab -e
    It will then be opened in the system's default text editor - usually Vi.

    Each line is divided into 6 sections each divided by a space. There may be spaces in the 6th section, but not 1 to 5. These first 5 sections represent the date/time values for when the job should run. The 6th section is the command to be run.

    There are different values that can be used for time intervals.

    The comma (',') allows for listing of values: e.g. 1,7,28,49
    The hyphen ('-') allows for range of values: e.g. 5-9 will mean 5,6,7,8,9
    The asterisk ('*') allows for all possible values: e.g. every minute, or day etc.
    The slash ('/') is interpreted as 'every': e.g /3 means every 3 minutes (ie /1 is the same as *)

    The 1st time digit represents the minutes (0-59)
    The 2nd time digit represents the hour (0-23)
    The 3rd time digit represents the day of month (1-31)
    The 4th digit represents the month (1-12)
    The 5th digit represents the day of week (0-6) [Sunday = 0 OR 7)

    Example 1 - Here the tmp directory would be cleared at 1am every day:
    Code:
    0 1 * * * rm /tmp/*
    Example 2 - Here the command will run every Monday at 2pm in March & July:
    Code:
    0 14 * 3,7 1 COMMAND TO BE RUN
    Example 3 - Run command every 3 minutes:
    Code:
    /3 * * * * COMMAND TO BE RUN
    Last edited by RecT; 05-04-2009 at 07:02 PM.
    Need to know your IP? Need to find WHOIS data for a website or IP address? Want to know your Google PageRank? Then you need Domain Tools!

+ Reply to Thread

Posting Permissions

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