First, homework (exercise) content:
1. Summarize the detailed usage method of the task plan (at, crontab) on Linux system;
At
Command explanation:
One-time task execution
At:at time
At >
Exact time:
hh:mm
Blur Time:
now+ #UNIT
Noon
Midnight
Tomorrow
Example: 23:00 execute cat/etc/fstab;
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc52a.tmp "border=" 0 "alt=" Wpsc52a.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/BD/wKioL1XsYU_iGnzLAABPiwpT8o8051.jpg "height="/>
Example: Execute IP a command after 10 minutes;
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc52b.tmp "border=" 0 "alt=" Wpsc52b.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/BD/wKioL1XsYU-CWsavAABJK1urjFI757.jpg "height=" "/>
Job View:
At-l,atq
To delete a job that has not been run:
at-d [Job number]
Submit Job: Ctrl+d
Job results: Sent to the user in the form of a message.
Send and receive mail:
Netstat-antlpt | grep 25
The default send and receive messages are only made between users on this computer and only through loopback addresses.
Mail
Q: Exit
N: View Nth message
Mail user
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc52c.tmp "border=" 0 "alt=" Wpsc52c.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/BD/wKioL1XsYU_RDoZIAAA7liRJbxw921.jpg "height=" "/>"
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc52d.tmp "border=" 0 "alt=" Wpsc52d.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/BD/wKioL1XsYU_Qce3yAADH4XG-Kbk753.jpg "height=" "/>
Mail-s "title" User
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc53d.tmp "border=" 0 "alt=" Wpsc53d.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/BD/wKioL1XsYU_xmoCmAAA0gd000TM693.jpg "height="/>
echo "Content" | Mail-s "title" User
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc53e.tmp "border=" 0 "alt=" Wpsc53e.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/BD/wKioL1XsYVDA8ydCAAArAMXev4k184.jpg "height="/>
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc53f.tmp "border=" 0 "alt=" Wpsc53f.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/BD/wKioL1XsYVDBMf7AAADlSDhcg1w180.jpg "height=" 153 "/>
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc540.tmp "border=" 0 "alt=" Wpsc540.tmp "src=" Http://s3.51cto.com/wyfs02/M02/72/BD/wKioL1XsYVCDReOMAAAO-5IA-Io978.jpg "height=" 6 "/>
Crontab
(1) Order Explanation:
Recurring Scheduled Tasks
(2) There are two types of crontab tasks
System crontab:/etc/crontab
User crontab: Defines a file with the same name as the user name in the/var/spool/cron/directory
Only one independent task can be defined per line
# 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
Point in time:
Minute hour day month week
Time notation:
1. Each time bit should be evaluated using its available valid range: * is used for all valid values.
17 * * * *
8 9 * * *
2.*/#, at the corresponding time bit valid value on every # time unit once
*/3 * * * * * run every 3 minutes
0 */3 * * * run every 3 hours
* */3 * * * * run every 3 hours every minute
(3) Continuous point-in-time
20 3 * * 1-6 weekly 1 to 6, 3:20
4. Discrete time points:
20 3 * * 2,4,6 per week 2,4,,6. 3:20 Execute Once
User-defined: crontab command
-L: Lists all tasks that have been defined
-E: Open the Edit Interface definition task
-R: Remove All Tasks
2, every Monday to Saturday 3:20 A.M., run the CP command to archive the/etc/directory, storage location is/BACKUPS/ETC-YYYY-MM-DD;
3 * * 1-6/bin/cp-a/etc/backups/etc-$ (date + '%y-%m-%d ')
3 * * 1-6/bin/tar-cvf/backups/etc-$ (date + '%y-%m-%d '). tar/etc
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc541.tmp "border=" 0 "alt=" Wpsc541.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/C1/wKiom1XsXyiT5qd7AABweZC_69g591.jpg "height="/>
3, every Sunday 2:30 A.M., run the CP command to backup the/etc/fstab file, the storage location is/BACKUP/FSTAB-YYYY-MM-DD-HH-MM-SS;
2 * * 7/bin/cp-a/etc/fstab/backup/fstab-$ (date + '%y-%m-%d-%h-%m-%s ')
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px ;p adding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc542.tmp "border=" 0 "alt=" Wpsc542.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/BD/wKioL1XsYVDyOl8KAABjNYem_DY711.jpg "height=" "/>"
4, every night 12 o'clock, get all the lines in the/proc/meminfo file starting with S or M, appended to the/statistics/meminfo.txt file, and the daily message before, to add a similar =============== separator line;
1 * * * echo ' =================================== ' egrep ' ^[sm] '/proc/meminfo ' >>/statistics/meminfo.txt
650) this.width=650; "Style=" background-image:none;border-bottom:0px;border-left:0px;padding-left:0px; padding-right:0px;border-top:0px;border-right:0px;padding-top:0px; "title=" wpsc553.tmp "border=" 0 "alt=" Wpsc553.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/BD/wKioL1XsYVHgaucAAABTotd4MSo938.jpg "height=" "/>:
20150905 after-school exercises