1.linxu Task Scheduler:
Task Schedule:
Perform a task at a future point in time: At,batch
Recurring tasks: crontab
e-Mail Service:
Smtp:simple Mail Transmission protocol
/var/spool/mail/username Personal Mail Buffer directory
Pop3:post Office Protocol
Imap4:internet Mail Access Protocol
Mua:mail command
Mail
Mail: Enter the interactive send and receive mail interface
Mail-s "SUBJECT" [email protected]
Mail-s "SUBJECT" [email protected] < echo "AAA"
Command | Mail-s "SUBJECT" [email protected]
AT command:
Commands to host future executions
Execute using Job queue
Default to a queue
Crtl+d
at [option].. Time
Time command:
1. Absolute time hh:mm Mmdd[cc]yy
2. Relative Time now+ time
Minut Hour day Week
3. Blur Time
Midnight Noon Teatime
Common options:
-Q queue at job queues
-f/path/filename read the developed file job from the specified file
-L View the list of running jobs in the job queue, equivalent to the ATQ command
-C At_job_num to get the details of the task to be job
-d Deletes the specified command job, equivalent to ATRM
Batch
The system chooses to run the specified task when the resource is idle
Crontab: Periodic execution of Mission plans
Daemon: Crond
There are two types of recurring tasks:
(1) System cron Task: The user identity is not run by default, so you need to specify additional running
/etc/crontab
Vim command
7 fields
Top 5 fields: Time field
Username: which user to run
Command: Run the order
(2) User Cron Task: Submitted by a user, run as submitter by default
/var/spool/cron/username
Vim command:
7 fields
Top 5 fields: Time field
Username: which user to run
Command: Run the order
5 Time points:
First field minute: Domain 0-59
Second field hour: domain 0-23
Third Field Day: Range 1-31
Fourth field month: Domain 1-12
Fifth field week: Domain 0-7
Note: It is not recommended to use both days and weeks of the month
Time notation:
Number: Indicates a specific point in time
*: At each point in time valid value range
-: A continuous time range, e.g. 3-7
,: A discrete time range, such as 3,5,7
/: How many times in the effective time range, specify the frequency of execution
crontab command
crontab [-u user]-l-r-E
-u User: Not running your own cron task, only administrators have permissions
-L: List cron tasks
-r: Delete cron task
-E: Edit cron Task
Supplemental tool: Anacron check for last cron not functioning automatically
Note: If you do not want to receive messages that command run results
COMMAND >/dev/null
Commadn &>/dev/null
For crontab file% there is a special meaning to use transfer escapes
Crontab's path variable is not exactly the same as the user environment variable and requires an absolute path
Practice:
1, every Monday to Saturday 3:20 A.M., run the tar command to backup the/etc directory, the backup directory is/BACKUP/ETC-YYYY-MM-DD.TAR.XZ
2, every Sunday 2:30 A.M., run the CP command to backup the/etc/fstab command, the backup path is/BACKUP/FSTAB-YYYY-MM-DD-HH-MM-SS
3, every night 12 o'clock, get all the lines in the/proc/meminfo file starting with S or M, append to the middle of/static/meminfo.txt to =============== as the delimiter.
1.[[email protected] ~]# CRONTAB-E20 3 * * 1-6 tar-czvf/backup/etc-$ (date ' +%f '). Tar.gz/etc/2. [[email protected] ~]# CRONTAB-E30 2 * * */* cp/etc/fstab/backup/fstab-$ (date ' +%f-%h-%m-%s ') 3. [Email protected] ~]# CRONTAB-E0 * * * echo "================================================" >>/statistics/ Meminfo.txt && Cat/proc/meminfo | Grep-e ' ^s|^m ' >>/statistics/meminfo.txt
Linux task management with Margo Linux (Lesson 5)