Usage of cron in UNIXLinux [Excerpt]

xiaoxiao2021-03-06  45

/ sbin / service crd Start // Startup Service / SBIN / Service Crond STOP // Close Service / SBIN / Service Crond Restart // Restart Service / SBIN / Service Crond Reload // Replacement

You can start this service when the system is started, and the end of the script in /etc/rc.d/rc.local: / sbin / service crond start

1. Edit the cron service with a crontab command to provide a cron service, the following is some of the parameters of this command with the description: crontab -u // set a user's cron service, the general root user is executing this command When you need this parameter crontab -l // lists a detailed cron -r // of a user cron service crontab -r // deletes a cron service cronTab-E / / edited a user's Cron service.

For example, root looks at your own CRON settings: crontab -u root -l

Another example, root wants to delete the Fred CRON settings: crontab -u fred -r

When editing the CRON service, the edited content has some formats and conventions, input: crontab -u root -e enters the VI edit mode, editing the content must meet the following format: * / 1 * * * ls >> /tmp/ls.txt This format is the setting of time, and a part is part of the command to be executed. If there is too much command to execute, you can write these commands inside, and then call this here The script is OK, remember to write the full path to the command. Time setting We have some agreement, the previous five * represent five numbers, the number of values ​​and meanings are as follows: Quote: Minute (0-59) Hours (0-23) Date (1-31) Month (1-12) Week (0-6) // 0 Represents Sunday, in addition to digital, there are several special symbols are "*", "/" and "-", "," represent all the value ranges The number, "/" represents every meaning, "* / 5" means every 5 units, "-" represents from a number to a number, "," separate several discrete numbers. The following example shows the problem: Quote: 6:00 every morning 0 6 * * * echo "good morning." >> /TMP/test.txt // Note Simple Echo, from the screen, no output, because cron Email any output email to the root's mailbox.

Every two hours 0 * / 2 * * * echo "Have a break now." /Tmp/test.txt

Every two hours from 8:00 in the evening, 8:23-7 / 2, 8 * * * echo "Have a good Dream :)" >> /tmp/test.txt

Every month's 4th and each week's worship will go to 11:00 am 11:00 11:4 4 * 1-3 Command Line

4:00 am on January 1 0 4 1 1 * Command Line

转载请注明原文地址:https://www.9cbs.com/read-51685.html

New Post(0)