Timed tasks named 3, at, batch, crontab
one. At command: at [option] time,at command is finished, input is completed with Ctrl+d time Way: & nbsp 1) hh:mm [yyyy-mm-dd] 2) noon, Midnight, Teatime (4 o'clock in the afternoon) & nbsp 3) tomorrow 4) now+#{minutes,hours , days, OR weeks}, such as at now+3minutes Common options: -q QUEUE: -l: Lists jobs waiting to be run in the specified queue; equivalent to atq   -D: Deletes the specified job; equivalent to atrm &Nbsp; -c: View specific job Tasks; -f/path/from/somefile: Reads a task from the specified file, performing multiple tasks at once, such as At-f At.task now+10minutes Note: The execution results of the job are notified to the relevant users by email;
two. Batch command:Allow the system to choose the free time to perform the tasks specified here, can not specify the time;
three. Recurring Task schedule: Cron 1) Related packages: (Rpm-qa | grep cron, Rpm-qi Cronie) Cronie: Main package with Crond daemon and related AIDS; Cronie-anacron:cronie, for monitoring Cronie task execution, such as when a task in Cronie has not run correctly in the past. Anacron will then start this task; Crontabs: include CentOS to provide system maintenance tasks;  2) Ensure that the Crond daemon is in a running state: centos 7: systemctl Status crond ...running ... Description started CentOS 6:      &NBsp; service Crond status
Four. System cron Task: System self-maintenance job, profile:/etc/crontab Example 1: Run the echo command at 9:10,  10 * * * Gentoo/bin/echo "howdy!" gentoo is user name  &N Bsp &NBSP ; Example 2: Echo command every 3 hours,   0 */3 * * * Gentoo /bin/echo "howdy!" note system cron needs to specify user identity   &NBSP ; Time Representation Method: (1 ) Specific Value; values in the range of valid values for a given point in time; (2) * all values in the range of valid values at a given point in time; says "Every ..."; (3) discrete value:, #,#,# (4) Continuous value:- #-# (5) Define step: for the specified time range /#: #即为步长
Five. User cron: crontab command definition, Each user has a dedicated cron task file:/var/spool/cron/username crontab Command: crontab [-u user] [-l |-r |-e] [-i] -l: List All Tasks;            -E: Editing Task; -r : Remove All Tasks; &nbsP; -i: Used with-R to enable users to selectively remove specified tasks in interactive mode; -u User: Only Root can run and manage cron tasks for designated users; Note: The results of the operation are notified to the relevant users by email; (1) COMMAND >/dev/null --do not send messages correctly (2) COMMAND &>/dev/null---Do not send mail, whether or not it is working correctly for cron tasks,% has a special purpose; If you want to use% in a command, You need to escape, however, if you place the% in single quotes, you may not have to escape;
six thinking: (1) How do I run a task at the second level? * * * * * for i in 0 1 2; Do echo "HI"; Sleep 20; Done ---once every 20 seconds (2) How do I run a task every 7 minutes? (because 7 cannot be divisible by 60, so */7 will have a problem), you can consider using the Sleep command  &NB sp; sleep number[suffix]... SUFFIX: s: seconds, default m: Min h: Hours d: Days Exercise: Directories need to be implemented to create good 1, every 4 hours to backup/etc directory to the/backup directory, save the file name format is "ETC-YYYY-MM-DD-HH.TAR.XZ"; 2, weekly 2, 4, 7 back up the/var/log/messages file to the/logs directory, The file name is shaped like "messages-yyyymmdd"; 3, remove the current system every two hours The information in the Proc/meminfo file that begins with S or M is appended to/tMp/meminfo.txt file; 4, weekday time, every small execution "IP Addr Show "command;
Linux Scheduled Tasks