summarize the detailed usage method of the task plan (at, crontab) on Linux system;
Task Scheduling on Linux:
The task plan is divided into:
Perform a task at a time in the future and achieve the target command: at Batch
Perform a task periodically in the next time, crontab
e-Mail Service:
Protocol: SMTP: Simple Mail Transfer Protocol
/var/spool/mail/username
Default mail directory for logged-on users
POP3: Post Office Protocol
IMAP4: Internet Access Protocol
Mail Service start or Not Status View: Netstat-tnl or SS-TNL
use of AT command :
Perform a task at once;
Ctrl+d Performing Tasks
at [OPTION]. .. Time
At-f/path/from/somefile Time
-Q queue:at Task job queue
-f/path/from/somefile ... Time: Reads the task job to run from the specified file
-L: View the list of pending jobs in the queue, equivalent to the ATQ command
-C At_job_num: View the contents of the specified pending job
-D: Deletes the specified job, equivalent to ATRM
crontab use of commands:
Crontab[-u user] [-l |-r |-e]
- u user : Instead of managing your own cron task, you specify a cron task for the target user, and root only has permissions to manage other users ' cron tasks, by default managing their own
- L List , List Tasks
- R Remove , remove All Tasks (note: Deleting a task should delete the row implementation via the edit interface)
- e Edit , open the Edit Interface Definition Corn Task
CRONTAB-E-U USERNAME
Topic:
1, every Monday to Saturday 3:20 A.M., run the tar command to save the/etc/directory for archiving, storage location is/BACKUPS/ETC-YYYY-MM-DD.TAR.XZ
[[Email protected] ~] #mkdir/backups/[[email protected] ~] #contab-E30 2 * * 7 cp/etc/fstab/backup/fstab-' date +%f-%h- %m-%s:wq[[email protected] ~] #crontab-L30 2 * * 7 cp/etc/fstab/backup/fstab-' date +%f-%h-%m-%s
2 , 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;
[[Email protected] ~] #mkdir-P/backup/fstab-' Date +%f-%h-%m-%s ' [[email protected] ~] #crontab-E 2 * * 7 Cp/etc/fstab /backup/fstab-' Date +%f-%h-%m-%s '
3,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;
[[Email protected] ~] #mkdir-P/statistics/meminfo.txt[[email protected] ~] #cat/proc/meminfo egrep ' ^s| M ' 0 0 * * */usr/bin/egrep (egrep ' ^ (s| M) '/proc/meminfo;echo "=================") >> Statistics/meminfo.txt
Linux OPS Practice-September 5, 2015 Course assignments