Linux has a service named Cron, which provides regular job scheduling.
Crontab is a command used to set jobs that are periodically executed. It is derived from the Greek Chronos, which is originally Time, And crond is its daemon.
The Linux system has a lot of routine work, so this service is started by default. You can use service crond status to check it out first. For security issues, you can use crontab user records in/etc/cron. deny. One user row.
When think uses the crontab command, its work will be recorded in/var/spool/cron/think. In addition, the Linux system records each job executed by cron to the/var/log/cron log file.
Crontab Syntax:
Crontab [-u username] [-L |-E |-R]
Parameters:
-U: only the root user can perform this task, that is, to help other users create/delete Job Scheduling
-L: Check the crontab job content.
-E: edit the crontab job content.
-R: delete all the job content of crontab. to delete an item, use-e
Example:
1) Send a mail to yourself at every day as think
Crontab-e
# At this time, the VI editing interface will be displayed for you to edit the work. Note that each job is a row and it is best to use an absolute path.
0 12 *** mail think-s "at" # Hour, day, month, week | command string ================== |
After editing, enter ": WQ" to save and exit VI.
2) if your girlfriend's birthday is July 22, May 2 and you want to send a letter to him at on July 22, May 1, the content of this letter is already in/home/dmtsai/lover.txt, how should we proceed?
Solution: 59 23 1 5 * mail Kiki
3) What should I do if I need to upload/home/dmtsai/test. Sh every five minutes?
Solution: */5 *****/home/dmtsai/test. Sh
All of the above are based on users. What about systems? Directly modify the/etc/crontab file.
There are three types:
1. Command type
0 1 *** think mail-s "testing" water Send think emails to water every hour
Second, directory
*/2 * root run-parts/root/runcron
Let root execute all executable files in/root/runcron every 2 minutes
Third, Program
*/5 * root/bin/MRTG/etc/MRTG/mrtg. cfg
Let root run the MRTG program under/etc/MRTG/every 5 minutes
Additional reading:
Http://linux.vbird.org/linux_basic/0430cron.php#cron
Http://www.cn-java.com/www1? Uid-560221-action-viewspace-itemid-8377
Http://blog.csdn.net/sipsir/article/details/3973713