The establishment of routine commands in Linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. Preface
If you want the server to connect to the audio and start music to wake you up at every morning, and at noon, you want Linux to send a letter to your email box, remind you that you can have lunch. In addition, send a letter to remind you one day before your lover's birthday every year to avoid forgetting such an important day ..... how can we achieve this goal? It is actually very simple. You only need to use crontab!
In fact, Linux has a lot of work in the context, especially when the network is open, establishing and canceling online, updating MySQL Databases in real time, and some routine system commands, for example, the memory is released. As there are a lot of routine work, it is impossible for the Administrator to manually enter it every day! Therefore, we need to understand how Linux establishes routine work!
Crontab has two methods to establish routine commands. One is for all users. You can issue work schedules using crontab-e commands; the other is for the system administrator. You can directly schedule the task by modifying the/etc/crontab text file! How can we execute the main crontab commands? Wait for laruence to come!
Use the crontab command
Create routine commands for individual users:
If you need to send a letter to yourself at every day, and the content of the letter has been written, what should you do? In addition, the other assumption is that your permissions on Linux Server only stop for common users and are not root (Administrator). How do you set your routine commands? Haha! Use the crontab command! You only need to execute crontab-e to enter the vi editing screen to edit your routine command!
[Vbird @ tsai vbird] # crontab-e
0 12 *** mail vbird@tsai.adsldns.org
In the preceding example, when you enter crontab-e, A vi screen will appear. Then, you can enter the above line in the vi screen, press: wq to save and leave! You can complete the editing! Easy! What does the above line represent? You can see that there are a total of five numbers before you really execute the command (that is, the mail vbird@tsai.adsldns.org
Minute (0-59)
Hour (0-23)
Date (1-31)
Month (1-12)
Week (0-6)
In addition, if it is "*", it indicates that all numbers apply. So you can know what the meaning of the line above is! That is no matter what month, day, day of the Day of the 12, execute the mail vbird@tsai.adsldns.org
• Example 1: If your girlfriend's birthday is July 22, you want to send a letter to him, the content of this letter has been written in/home/vbird/lover.txt. How do you edit it? Haha, use:
[Vbird @ tsai vbird] # crontab-e 59 23 1 5 *
Mail pigpp@tsai.adsldns.org
• Can it be ?? Eggplant? Maue? Hey, pigpp will receive your letter! (Of course ??? Which of the following statements does it mean? Hey, hey, you know.
• Example 2: If you want to check one of your files named test. sh every five minutes! What should I do?
[Vbird @ tsai vbird] # crontab-e */5 *****/home/vbird/test. sh
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