Basicly Cron is a Task Scheduler.
You can run any command on a specific schedule.
Cron uses CRONTAB(cron tables) to read the commands.
You can say that crontab is somekind of a database.
You can edit crontab by the crontab command and give cron commands by the cron command.
Crontab usage.
Crontab is made of fields, each field represents a specific value:
Field 1 -> Minutes (range: from 0 to 59)
Field 2 -> Hours (range: from 0 to 23)
Field 3 -> Days (range: 1-31)
Field 4 -> Months (range: 1-12)
Field 5 -> Day of the week (range: 0-6, starting from sunday)
Field 6 -> Your command.
Let's say that you want to run some script(let's anem the script.. ermm.. X.sh) every friday to sunday at 5 pm.
So your entry would be:
0 17 * 5-0 /home/user/X.sh
And let's say that we want to delete some logs every 6 month(let's begin on June) on the 3rd of the month at 1 pm:
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
So you got the idea..
Now, let's make our own Crontab list and insert the 2 entries above into it and then run cron for output. (You can also modify the original crontab, but it doesn't work for me for some reason)
So we create a new file.. hmm let's call it MyCrontab.txt
And give it the 777 CHMOD to avoid some errors =P
now, insert into MyCrontab.txt your entries. For us they would be:
0 17 * 5-0 /home/user/X.sh
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
and save MyCrontab.txt.
Now access your favorit terminal and use the crontab command, like this:
[user@localhost home]$ crontab MyCrontab.txt
after that you should check if the list has applyed:
[user@localhost home]$ crontab -l
0 17 * 5-0 /home/user/X.sh
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
If the above was your output, that means that you're fine.
Now, about the cron output..
You can do this with 2 ways:
1. Cron will send you an eMail.
2. Cron will place the logs into a text file.
Usage:
1. In MyCrontab.txt that we've created, we place at the top:
MAILTO="xxx@xxx.xxx"
and after that we place all of the entries.
2. We add another command to our entry(ies):
0 17 * 5-0 /home/user/X.sh >> /home/user/cron/log.txt
0 13 3 6 * rm -f /home/user/deadly/logs/*.* >> /home/user/cron/log.txt
If you don't want to log, you can just ignore the >> .
That about everything I know =\
Enjoy! xD
Copyleft 2005 Helios Zepp.
You can run any command on a specific schedule.
Cron uses CRONTAB(cron tables) to read the commands.
You can say that crontab is somekind of a database.
You can edit crontab by the crontab command and give cron commands by the cron command.
Crontab usage.
Crontab is made of fields, each field represents a specific value:
Field 1 -> Minutes (range: from 0 to 59)
Field 2 -> Hours (range: from 0 to 23)
Field 3 -> Days (range: 1-31)
Field 4 -> Months (range: 1-12)
Field 5 -> Day of the week (range: 0-6, starting from sunday)
Field 6 -> Your command.
Let's say that you want to run some script(let's anem the script.. ermm.. X.sh) every friday to sunday at 5 pm.
So your entry would be:
0 17 * 5-0 /home/user/X.sh
And let's say that we want to delete some logs every 6 month(let's begin on June) on the 3rd of the month at 1 pm:
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
So you got the idea..
Now, let's make our own Crontab list and insert the 2 entries above into it and then run cron for output. (You can also modify the original crontab, but it doesn't work for me for some reason)
So we create a new file.. hmm let's call it MyCrontab.txt
And give it the 777 CHMOD to avoid some errors =P
now, insert into MyCrontab.txt your entries. For us they would be:
0 17 * 5-0 /home/user/X.sh
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
and save MyCrontab.txt.
Now access your favorit terminal and use the crontab command, like this:
[user@localhost home]$ crontab MyCrontab.txt
after that you should check if the list has applyed:
[user@localhost home]$ crontab -l
0 17 * 5-0 /home/user/X.sh
0 13 3 6 * rm -f /home/user/deadly/logs/*.*
If the above was your output, that means that you're fine.
Now, about the cron output..
You can do this with 2 ways:
1. Cron will send you an eMail.
2. Cron will place the logs into a text file.
Usage:
1. In MyCrontab.txt that we've created, we place at the top:
MAILTO="xxx@xxx.xxx"
and after that we place all of the entries.
2. We add another command to our entry(ies):
0 17 * 5-0 /home/user/X.sh >> /home/user/cron/log.txt
0 13 3 6 * rm -f /home/user/deadly/logs/*.* >> /home/user/cron/log.txt
If you don't want to log, you can just ignore the >> .
That about everything I know =\
Enjoy! xD
Copyleft 2005 Helios Zepp.
