Linux Cron Learning System

Source: Internet
Author: User
Tags mrtg crontab syntax

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.