|
Automating Tasks in Linux using Cron Linux has a powerful task scheduler called Cron. Cron will allow you to
run commands automatically at times specified by you. Cron is similar to the
task scheduler you find in Windows. To keep track of the schedules and tasks
it has to run, Cron requires a file called Crontab (CRON TABle). All the
Cron schedules and tasks should be stored in this table. The Crontab files
cannot be directly edited. You can add or delete entries in the crontab file
using the crontab command.
What's Cron and Crontab ?
You must be wondering what the difference between cron and crontab or wether
they are the same. Cron is a process or program which wakes up every minute
and looks for jobs it has to execute at that moment. Crontab is the list of
jobs and times at which they have to execute.
Crontab Format:
Each entry in Crontab has at least 6 fields separated by a single space.
Field 1 Minute Range of Values : 0-59 Field 2 Hour Range of Values : 0-23
Field 3 Day Range of Values : 1-31 Field 4 Month Range of Values : 1-12
Field 5 Day of week Range of Values : 0-6 (Sunday being 0) Field 6 Command
to Execute
Now let's see how to make a crontab entry. Let's say you want to run a
script backup.sh every day at 6:00pm.The entry would look like this:
0 18 * * * /home/user/backup.sh
The asterisk (*) is used to indicate that every instance of the particular
time period will be used (i.e. every hour, every weekday, etc.). I've used
to full path to the script /home/user/backup.sh instead of just using
backup.sh. This is because cron runs as root, you should fully qualify your
path names to any scripts that will be run. Let's see some more examples :
* Let's run the script printinvoices.sh every sunday at 12:45pm.
45 12 * * 0 /home/account/printinvoices.sh
* How about clearaccount.sh every month beginning at 1:32am ?
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 the crontab
list. To do this, you can use the crontab command. By specifying the -e
option, you'll be taken to the 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 the following command: [crontab mycrontablist] where mycrontablist is
the file containing your entries.
Viewing Crontab: [crontab -l]
You can view your current crontab list by specifying the -l option. Issuing
this command will print out a list of all your current jobs in the crontab
list
Removing Crontab: [crontab -r]
The -r option removes your current crontab file. Issuing this command will
empty the contents of the current user's crontab file
Output from cron
Usually the output of cron gets mailed to the owner of the process or the
person or email id specified in the MAILTO variable. To set the MAILTO
variable, you'll have to add the following command to the top of your
crontab : MAILTO="your_email_address@domain.com"
If you have a command that is run frequently, and you don't want the output
to be emailed each time, you can redirect the 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 the output to a null
file : cmd>>/dev/null
0 18 * * * /home/user/backup.sh>>/dev/null
About the Author
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
Additional Backup linux uk Resources
Fortuna suppliers of Linux backup software from BakBone
Within this site you will find useful information regarding Linux backup software for backing up many operating systems and applications. UK based.
Arkeia, Intelligent Backup Solutions
... of enterprise-class backup and restore solutions focused on Linux for heterogeneous environments ... Select an Arkeia Website USA UK & Ireland Germany France Switzerland Austria Belgium ...
Scary Backup Stories | Linux Journal
Subscribe Now. Since 1994: The Original Monthly Magazine of the Linux Community. Current Issue ... of Computer Science ARPA: miw%uk.ac.man.cs.ux@cs.ucl ... common to perform backup using ...
Backup for Linux
UNiBACK is an efficient, powerful backup solution for the Linux operating system.
Linux Backup Software
BakBone NetVault Linux Backup Software for LAN, SAN, NAS or SCSI attached storage backup. BakBone NetVault is designed for use in either workgroup,...
Arkeia Grows UK presence with appointment of distributor Interactive I
... added distributor of Linux software to provide award-winning backup solutions in the UK and Ireland ... Arkeia solutions to the broader UK Linux, enterprise VAR and reseller channel ...
SOFTWARE PARADISE UK - BUY ARCserve Backup Linux Lic No M software by.
...Buy ARCserve Backup Linux Lic No M by BrightStor software from Software Paradise UK - The UK's.....Click here for ARCserve Backup Linux Lic No M by BrightStor.. Buy a full range of ...
Orbit Software
ORBiT Software provides backup software, UNiBACK, for MPE, Linux, and NT, specializing in managing information with backup, compression and distributed access products.
Zangband Savefile Backup Shell Script
Shell script, designed for Linux, that allows you to easily backup and restore your savefile.
Linux backup utility
Linux backup utility. You are looking on linux backup utility deals. ... io-design.org.uk, All rights reserved...
Linux Amupost
...Toxic installing linux UK search engine is your refreshing guide to the Internet in the UK.....linux anti virus linux application linux backup linux boot disk linux certification linux ...
Linux System Backup and Disaster Recovery
Storix Backup Administrator for Linux is a full-featured local and network backup management product that also provides flexible system installation and recovery.
Linux file backup
We found following result on your "Linux file backup" request ... Website index | Add to favorites © io-design.org.uk, All rights reserved...
Linux.com | Mondo Rescue LiveCD backup: a nugget of gold
Mondo Rescue LiveCD backup: a nugget of gold -- article related to System Administration and Servers. ... Using the LiveCD backup functionality of Mondo Rescue is all ... Clone an ...
Searchsmarter.co.uk | Directory | Computers | Systems | Linux System
...dedicated linux hosting..dedicated linux server..download linux mandrake..ecuador hosting.....linux disaster recovery..linux disk backup..linux disk recovery..linux distribution..linux ...
Other Recommended Backup linux uk Links
Linux backup tar
Linux oracle cluster
Access cluster free linux
Cluster linux manegment sof...
Bladecenter linux cluster
Hpc linux cluster
Linux cluster software
Download red hat linux 9
How to install red hat linu...
Red hat linux 9 tutorial
Linux help desk software
Help desk linux
Blogspot.com desk help linu...
Suse linux help
Mandrake linux help
|