Scheduled Tasks small drill

1, showing the largest memory footprint statistical process system, and sorting.

[root@centos7-1data]#ps aux | sort -k4 -nr | head -n1

2, scripting, and while use for network segment 192.168.0.0/24 are achieved, if the address can ping, ping the output if "success!", If not General ping output "fail!"

 

3, weekly working days 1:30 to / etc to backup / backup directory to save the file name format is "etcbak-yyyy-mm-dd-HH.tar.xz", which is the day before the date of time

(1) Create a backup directory

[root@centos7~]#mkdir backup

(2) modify the execution script and execute permissions plus

[root2centos7 ~] Vim back_etc.sh 
the tar JCF / the root / Backup / etcbak-`date -d 'Day -1' +% F-% H`.tar.xz / etc / &> / dev / null is written script content 
chmod + x back_etc.sh plus execute permissions

(3) write Scheduled Tasks

[root@centos7~]#crontab -e
30  1   *  *  1-5  /root/back_etc.sh

4, working time, every 10 minutes to perform a check disk space, any partition if it is found higher than 80% utilization, sends an alarm message

(1) content to be executed first written into the script

[root @ centos7data] #vim wall.sh 

#! / bin / bash 
# 
# ******************************** ************************************ 
#Author: liudalao 
# QQ: 77,421,225 
#Date: 2019-11 -24 
#filename: wall.sh 
#URL: http://www.struggle.com 
#description: the Test Script at The 
#Copyright (C): 2019 All Rights Reserved 
# ************* ************************************************** ***** 
[ `DF | grep / dev / SD | -NR Sed '. /.* S ([0-9] +) *% / \. 1 / P' | Sort -NR | head gt -1` 80] && result is not displayed on the screen wall disk will be full to be performed directly deposited into the trash

(2) plus the script execute permissions

[root@centos7data]#chmod +x wall.sh

(3) can then execute the script in the scheduled task

[root@centos7~]#crontab -e

*/10  *  *  *  0 /data/wll.sh

  

Guess you like

Origin www.cnblogs.com/struggle-1216/p/11924767.html