Go Back   Computer Support Forum - Free IT Hardware & Software Help > Internet > Web Server Management

Web Server Management Discuss all aspects of setting up and running a web hosting server or business.

Closed Thread
 
Thread Tools Display Modes

Tutorial: Crontab Editing
  #1  
Old 05-04-2009, 06:58 PM
RecT RecT is offline
Super Moderator
 
Join Date: Nov 2007
Posts: 189
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
__________________
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!

Last edited by RecT; 05-04-2009 at 07:02 PM..
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT +1. The time now is 01:28 PM.


vBulletin skins developed by: eXtremepixels
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Computer Forum, Comp Forum, Tech Support Forum, Free CPanel and MiLon Hosting are part of MiLon Technologies.