Linux under the Add Scheduled Task

Linux, you can add one-off scheduled tasks and long-term planning tasks, the following simple understanding, the project is built on the rear face of its own cloud host may be helpful.

Disposable Scheduled Tasks

Use the command to set the time at a one-time scheduled tasks, at -l command to view the task, atrm task numbers can delete a task.

Interactive add links

The default mode is interactive, using at the time the command, enter the command to be executed in the task at> back, press ctrl + d exit interactive. As shown creates a one-time task, create a log.txt file in the / tmp directory.

Non-interactive add links

Non-interactive mode need to use the pipe command, such as echo command | at the time, so that at the output of the command information received echo command to achieve the purpose of the mission added.

You can see, at a specified point in time, the text is appended to the log.txt, where at -l can view the list of tasks, atrm numbers can delete a task, do the demo here temporarily.

Periodic task

You can use crontab -e command to enter the vim editor interface to create recurring tasks, crontab -l to view the task, crontab -r is used to delete a task. First, understand the format of the next periodic tasks, consists of two parts, the front is a time-dependent, if time is not set to write * in place, followed by the command.

(1) point: integer 0-59

An integer of from 0 to 23: (2)

(3) Date: integer 1-31

Integer 1 to 12: (4) months

(5) week: 0-7 integer, 0 and 7 for Sunday

(6) command: Command to use absolute paths.

Wherein the plurality of parameters may be separated by commas, such as Jan Feb Mar, 1,2,3 representation may be used to express an interval if, as of January to March, expressed on the use of 1-3, / can may represent a time interval, such as * / 2 indicates every one minute.

Here a simple periodic task set at one minute intervals to the input text file log.txt.

Others do not show, according to the needs of their own DIY, you want to add the task to add a line tasks using crontab -e, to remove to use crontab -r to delete. It should be noted that the division can not be empty or *, day and week can not be set at the same time, there may be a conflict.

 

Reference Hirofumi:

(1) "linux in respect of such a study."

Guess you like

Origin www.cnblogs.com/youngchaolin/p/11722994.html