Tip of the Week 2005-08-15
From FedoraNEWS.ORG
Welcome to Tip of the Week!
Tip of the Week releases on every monday with Fedora Weekly News.
Tip of the week: How to Have Tasks Run at Specified Times
This will help you use cron for tasks you want performed regularly, such as making backups, or shutting down the computer - submitted by Tejas Dinkar
cron is a program that is essential to a UNIX file system. Many System operations of the operating system are managed by the cron daemon, crond for short.
Before trying to use cron, first ensure crond is enabled. This can be seen in system-config-services, and it is enabled by default
Cron is executed once a minute. To see the jobs cron will run, and it's times, you type in the command:
crontab -e
It will open the editor vi. If you would rather use pico or nano for editing, type
export VISUAL=nano crontab -e
Every crontab entry is on a single line. It is in the form:
<min> <hour> <Day of Mon> <Month> <Day of Week> <usr> <Command>
<usr> is optional.
Cron will check each field, and if the current time matches each column, then the command at the end of the line is executed
* can be used as a wildcard, implying true for all values
example:
00 13 * Jun Mon tar zcvf /var/backup.tar.gz /home 00 13 * 6 1 tar zcvf /var/backup.tar.gz /home
both do the same thing. Make a backup of /home at 1:00PM On Every Monday in June
The - can be used to declare a range, and / can be used to describe the corresponding step.
00 13-19/2 * Jun Mon myuser tar zcvf /var/backup.tar.gz /home/myuser
This will do the same thing as the previous, except that the user 'myuser' is backing up his data. Also, this will be executed at 1PM, 3PM, 5PM, and finally 7PM.
The final useful modifier is the ',', which is used to imply multiple values.
00 00 1,16 * * reboot
will reboot the machine on the 1st and 15th of each month, at exactly midnight.
Note: Fedora also comes with a program called Anacron. Anacron will execute all of the things that was supposed to be executed when the computer was shut down. Anacron runs and executes everything at boot. You may or may not want this enabled, and you can toggle this in system-config-services
Previous Tips of the Week Can be found Here: Tips of the IceBurg
Add a Tip
If you have a tip you want to add, contact Tejas Dinkar (mailto:tejasdinkar@gmail.com).

