As long as any user is not included in/etc/cron. deny, he can directly issue "crontab-e" to edit his or her routine commands! As mentioned above, the entire process will go to the VI editing screen and edit it with a work line. After editing, enter ": WQ" to save and Leave Vi! The format of each task is "five time parameter actual action instructions". What are the five time parameters?
Meaning |
Minutes |
Hours |
Date |
Month |
Week |
Number range |
0-59 |
0-23 |
1-31 |
1-12 |
0-7 |
What's interesting is the week! When the week is 0 or 7, it means "Sunday! In addition, there are some auxiliary characters, which are roughly the following:
Special characters |
Meaning |
* |
Meaning accepted at any time! For example, the example 1 in the above table indicates that the day, month, and week are all *, which means that "the subsequent commands are executed at on every day of the week, no matter what month or day! |
, |
It indicates the meaning of the separated time periods. For example, if you want to release a job at and, it will be:
There are still five columns, but the second column is 3, 6, which indicates that both 3 and 6 are applicable! |
- |
For example, during a period of time, every hour between and has a job:
The second column is changed to 8-12! It indicates that 8, 9, 10, 11, and 12 are applicable! |
/N |
That N represents the number, that is, the meaning of "every n units interval", for example, once every five minutes, then:
Easy! Use * And/5 together, or enter 0-59/5! |
Let's take a look at the exercises with several examples!
Example: If your girlfriend's birthday is July 22, May 2 and you want to send a letter to him at on July 22, May 1, the content of this letter has already been written in/home/dmtsai/lover.txt. How can this problem be solved? A:
|
Example: What if/home/dmtsai/test. Sh needs to be executed every five minutes? A:
Similarly, use crontab-e to enter the editing page:
*/5 */home/dmtsai/test. Sh
|
Each crontab has only one file, which is in/var/spool/cron! We also recommend that you: "When the command is down, it is best to use the absolute path, so that the execution file will not be found !』
Example: If you have an appointment with a friend on Saturday every week and want to tell your friend not to forget his appointment on Saturday at every Friday, then: A:
Still use crontab-e!
30 16 ** 5 mail friend@his.server.name
|
Crontab: Command not found
In this case, the system path is not loaded in your shell environment.
Therefore
Source/root/. bash_profile
Source/etc/sysconfig/i18n
Generally run as root:
Crontab-e
Then enter the command:
For example, */5 *** source/etc/profile CD/home/William/chenjilogdigger/; Mongo localhost: 27017/log Stat. js
Save
Note that a job is written as one line,