Continued from page 1
21 1 1 * * /home/accont/clearaccount.sh
* Let's see how to schedule a task to run only on weekdays(monday to friday)
0 10 * * 1-5 /home/account/cleartemp.sh
Adding and Editing Entries in Crontab and Now that you know how crontab entries are formated, it's time to put some of your entries into
crontab list. To do this, you can use
crontab command. By specifying
-e option, you'll be taken to
default text editor to add and edit your crontab list. [crontab -e]
Another method of manipulating your crontab entries is to create and save a text file with your crontab entries. You can load your list into crontab by using
following command: [crontab mycrontablist] where mycrontablist is
file containing your entries.
Viewing Crontab: [crontab -l]
You can view your current crontab list by specifying
-l option. Issuing this command will print out a list of all your current jobs in
crontab list
Removing Crontab: [crontab -r]
The -r option removes your current crontab file. Issuing this command will empty
contents of
current user's crontab file
Output from cron
Usually
output of cron gets mailed to
owner of
process or
person or email id specified in
MAILTO variable. To set
MAILTO variable, you'll have to add
following command to
top of your crontab : MAILTO="your_email_address@domain.com"
If you have a command that is run frequently, and you don't want
output to be emailed each time, you can redirect
output to a log file cmd >> log.file, so your job would be something like this.
0 18 * * * /home/user/backup.sh>>log.file
If you don't want any output at all, you can redirect
output to a null file : cmd>>/dev/null
0 18 * * * /home/user/backup.sh>>/dev/null

Vinu Thomas is a consultant on Web design and Internet Technologies. His website is http://www.vinuthomas.com. You can read more articles on Linux @ http://www.vinuthomas.com/sections-listarticles-6.html