Linux _ crontab

Source: Internet
Author: User


Linux _ crontab is used to allow users to execute programs at a fixed time or interval. In other words, it is similar to the user's time table. -U user is used to set the time table of the specified user. The premise is that you must have the permission (for example, root) to specify the time table of another user. If-u user is not used, the time table is set. ========================================================== ================================== common parameters: crontab-l // view the cron task crontab-e under the current user // edit the current user's scheduled task crontab-u linuxso-e // edit the scheduled task of linuxso ==== ========================================================== ============================ basic format: www.2cto.com ***** command minute-by-day, month, week, command column 1st indicates minute 1 ~ 59 every minute, use * or */1 to indicate 2nd columns to indicate hour 1 ~ 23 (0 indicates 0 points) column 3rd indicates date 1 ~ 31 column 4th indicates the month 1 ~ 12 column ID No. 0 ~ 6 (0 indicates Sunday) the command to be run in the 6th column ============================================ ============================ example: 50 7 ***/sbin/service sshd start means to enable the ssh service at every day 50 22 22 ***/sbin/service sshd stop means to close the ssh service at every day **** */home/mydata. sh indicates that the executable file mydata under the/home directory is executed once every minute. sh more examples: http://www.bkjia.com/ OS /201207/140685.html =================================================== ======================================
The function is as follows: the system writes the system time to A/home/mydata file every minute, to copy the mydata file to the/root directory, we can implement this function in two ways: Step 1: add the task to the crontab-e www.2cto.com in the task scheduler. Enter the vi operation interface: * ***** date>/home/mydata ***** cp/home/mydata/root save and exit. Method 2: Step 1: Create an executable file/home/myfile. sh vi myfile. sh to enter the vi operation interface, enter: date>/home/mydata cp/home/data/root to save and then exit.

Step 2: Modify the permission of the myfile. sh file chmod 744 myfile. sh

Step 3: add the task scheduling crontab-e To Go To The vi operation interface. Enter *****/home/myfile. sh to save and exit. Www.2cto.com

========================================================== ================================== Running effect: /home directory:


/Root directory:



Author: Hongten

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.