How to use crontab to execute scripts regularly
Today, I will talk to you about how to use crontab to execute scripts regularly, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Let's first introduce the crontab: crontab command, which is common in Unix and Unix-like operating systems, and is used to set instructions that are executed periodically. This command reads instructions from a standard input device and stores them in a "crontab" file for later reading and execution.
After saying so much, you may not understand. In fact, it is used to execute a file or command on a regular basis.
For example, under macOS, we can do this to make the system say a word every minute:
Enter crontab to edit: sudo crontab-e
Enter: * say alltoshare after entering the vi editor
(PS: if you are not familiar with vi, you can search for the operation. It is relatively simple here. Press I to enter, press Esc after typing, and then type: wq)
In this way, the system will say alltoshare every minute.
We can also write a script file.
In this way, it will execute the script file every minute.
If you want to change the scheduled operation time, you can see here, I will not repeat it: http://www.jb51.net/LINUXjishu/19905.html
Basic format:
* command
Time-sharing, day, month and week order
Column 1 represents minutes 1: 59 per minute is represented by * or * / 1.
The second column represents the hour 1: 23 (0 means 0 o'clock)
The third column represents the date 1: 31
The fourth column represents the month from January to December.
The fifth column identification number is 0006 (0 means Sunday)
Column 6 commands to run
After reading the above, do you have any further understanding of how to use crontab to execute scripts regularly? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.