Perform one task at a time in the future: at, Batch
To run a task periodically: cron
e-Mail Service:
Smtp:simple Mail Transmission protocol for mail delivery
Pop3:post Office Protocol
Imap4:internet Mail Access Protocol
Mailx-send and receive Internet mail
Mua:mail User Agent
MAILX [-S ' SUBJECT '] username[@hostname]
The message body is generated:
(1) give directly, Ctrl+d;
(2) Input redirection
(3) through the pipeline
Echo-e "How is you?\nhow old is you?" | Mail
AT command:
At [option] Time
Time:
hh:mm [YYYY-MM-DD]
Noon, midnight, teatime
Tomorrow
Now+#{minutes,hours,days, or weeks}
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
-C: View specific job Tasks
-f/path/from/somefile: Reading a task from a specified file
Note: The execution result of the job is notified to the relevant user by mail
Batch command:
Allow the system to choose its own idle time to perform the tasks specified here
Recurring Task Scheduler: Cron
Related packages:
Cronie: Main package, provides Crond daemon and related auxiliary tools
Cronie-anacron:cronie to monitor the execution of Cronie tasks, such as when a task in Cronie has not run correctly at a point in time in the past, Anacron will then initiate this task
Crontabs: Includes centos to provide system maintenance tasks
Make sure that the Crond daemon is in a running state:
CentOS 7:
Systemctl Status Crond
CentOS 6:
Service Crond Status
The tasks that are scheduled to be performed periodically are submitted to Crond, which is implemented to the point of operation.
System Cron Task: System maintenance Job,/etc/crontab
User Cron task: crontab command
System Cron Task
# Example of Job definition:
#.----------------Minute (0-59)
# | .-------------Hour (0-23)
# | | .----------Day of Month (1-31)
# | | | .-------month (1-12) OR jan,feb,mar,apr ...
# | | | | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * * user-name command to be executed
Example: Run the echo command at 9:10
* * * * gentoo/bin/echo "howdy!"
Time notation:
(1) A specific value: A value 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, indicating "every ..."
(3) Discrete value: #,#,#
(4) Continuous value:-,#-#
(5) in the specified time range, define the step length,/#: #即为步长
Example: Echo command every 3 hours
0 */3 * * * gentoo/bin/echo "howdy!"
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 tasks
-R: Remove All Tasks
-I: Use with-R to allow users to selectively remove specified tasks in interactive mode
-U User: Only root can run, manage cron tasks for designated users
Note: The result of the operation is notified to the relevant user by email
(1) COMMAND >/dev/null
(2) COMMAND &>/dev/null
Note: For cron tasks,% has a special purpose; If you want to use% in the command, you need to escape, but if you put% in single quotes, you can also not escape
This article is from the "Ricky Technology Blog" blog, make sure to keep this source http://r1cky.blog.51cto.com/10646564/1773863
Linux Task Scheduler, recurring task execution