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