Home > other >  Regularly check system CPU, memory, the usage of the root partition, test script writing good, but I
Regularly check system CPU, memory, the usage of the root partition, test script writing good, but I

Time:10-15

#!/bin/bash
# usage statistics system xitong () {
Yum install sysstat 10.1.5-12. El7. X86_64 - y & amp;>/dev/null
CPU=` SAR -u 1 5 | | tail - 1 awk '{print $8}' | awk - f. '{print $1}' `
FREE=$((- $100 CPU))
If [$FREE - gt 80]
Then echo "your CPU usage is $FREE %, % more than 80" the else echo your CPU usage is $FREE, belong to "normal"
Fi
TOT=$(free | grep Mem | awk '{print $2}')
USE=$(free | grep Mem | awk '{print $3}')
2=$(($USE * 100/$TOT))
If [$2 - gt 90]
Then
Echo "your memory space utilization rate of $% 2, has more than 90%"
The else
Echo "your memory usage for $% 2, belong to the normal"
Fi
ROOT=$(df - hT | grep '/$| awk' {print $6} '| awk - F %'} {print $1 ')
If [$ROOT - gt 90]
Then
Echo "your hard packing partition utilization rate more than 90% to $ROOT %" else
Echo "you hard packing partition utilization rate is $ROOT %, belongs to the normal"
Fi
}

Me=` whoami ` & amp;>/dev/null
The cat & lt; 1 * * * * *//usr/bin/sh xitong
EOF

CodePudding user response:

30 minutes to perform

CodePudding user response:

Crontab -e
30 * * * * */usr/bin/sh script absolute path
You should write in the project task, not written in the script

CodePudding user response:

Crontab -e
Add: #
30 * * * * bash file path
Keep out!

2 floor configuration more than a '*'
no.

CodePudding user response:

This script written can also, see your ability is good, can try to IT delivery network (http://www.itjiaofu.com/) to find oneself is good at the task of part-time job, you have the ability, we have a platform