Cron продолжает работать каждые 1 или 2 минуты

Я заметил, что мой cron-скрипт продолжает работать через 1 или 2 минуты после выполнения в течение почти 1 часа, так как у меня много рабочих заданий cron, иногда я не могу получить доступ к моему сайту, браузер продолжает искать долгое время :

# Check disk space each 5 AM everyday
* 5 * * * /root/Scripts/Misc/disk_space.sh

disk_space.sh проверит дисковое пространство в каждом разделе и уведомит меня по электронной почте, если дисковое пространство больше 95%

disk_space.sh [ ! d2]

#!/bin/bash

#output=$(df -h | awk '{ print $5 }')

# Define date and time
Now=$(date +"%d-%m-%Y %T")

# Define hostname
hostname=$(hostname)

# Set alert limit, 95% we remove % for comparison
alert=95

# $1 is the partition name
# $5 is the used percentage
# NR>2: Start reading from row 2, otherwise will start reading from Strings (Use%)
# result of df -h will start output from Filesystem      Size  Used Avail Use% Mounted on
# and we cannot compare strings to digits while using -eg

# Print the df -h, then loop and read the result 
# NR>2: start reading from horizontal line number 2
df -h | awk 'NR>2 { print $1 " " $5 }' | while read output;
do

#echo $output

# Get partition name
partition=$(echo $output | awk '{ print $1 }')
#echo 'Partition: ' $partition
# Used space with percentage
useSpPer=$(echo $output | awk '{ print $2}')
#echo 'Used space %: ' $useSpPer

#used space (remove percentage)
useSp=$(echo -n $useSpPer | head -c -1)
#echo 'Used space digit: ' $useSp

#useSpDg=$(sed '1d' $useSp)
#echo $useSpDg

# Recap
#echo $useSp ' has ' $partition

# -ge is greatter than or equal
#echo "DEBUG [$useSp] [$alert]"

if [ $useSp -ge $alert ]; then
#echo $partition 'is running out of space with '$useSpPer

echo $Now ' ' $partition ' ' $useSpPer >> /root/Scripts/Misc/disk_space.log

dfRes=$(df -h)

# Inform the admin
echo -e "The partition $partition belongs to the host: $hostname is running out of space with $useSpPer.\n\nThis is the full result: \n\n$dfRes \n\nThis message is a warning to take an action, sent on $Now \nThank you for using this script" 2>&1 | sed '1!b;s/^/To: MAILID\nSubject: '$hostname': Disk Space\n\n/' | /usr/sbin/sendmail -t
#else
#echo 'Down'

fi

done
#echo $output

Спасибо четыре вашей поддержки

1
задан 25 March 2016 в 17:17

0 ответов

Другие вопросы по тегам:

Похожие вопросы: