Skip to main content
added 31 characters in body
Source Link
peterh
  • 10.5k
  • 18
  • 70
  • 99
#!/BIN/BASH
# To alert whenever lsof crosses 80%

maxlimit=32000
echo 'Max limit is ' $maxlimit
tlimit=$(bc <<< $maxlimit*0.8)
echo 'Treshold limit at 80% ' $tlimit
a=$(lsof | wc -l)
echo 'Current usage ' $a
if [ $(bc <<< "$a > $tlimit") -eq 1 ]
then
        echo 'lsof =' $a 'has exceeded 80% of maximum limit' | /usr/bin/Mail -s "ALERT!!!" "*****@cisco.com"
fi

* * * * * bash /root/vasanth/lsef/script.sh

In the above script The, the output is to send a mail to the corresponding Mail ID . When

When I run it manually it sends the mail When.

But, when it is scheduled in CRONTAB Mail isntcron, the mail is not being sent.

I cant understand what the problem is........ How could I debug it?

#!/BIN/BASH
# To alert whenever lsof crosses 80%

maxlimit=32000
echo 'Max limit is ' $maxlimit
tlimit=$(bc <<< $maxlimit*0.8)
echo 'Treshold limit at 80% ' $tlimit
a=$(lsof | wc -l)
echo 'Current usage ' $a
if [ $(bc <<< "$a > $tlimit") -eq 1 ]
then
        echo 'lsof =' $a 'has exceeded 80% of maximum limit' | /usr/bin/Mail -s "ALERT!!!" "*****@cisco.com"
fi

* * * * * bash /root/vasanth/lsef/script.sh

In the above script The output is to send mail to the corresponding Mail ID . When I run it manually it sends the mail When it is scheduled in CRONTAB Mail isnt being sent

I cant understand what the problem is........

#!/BIN/BASH
# To alert whenever lsof crosses 80%

maxlimit=32000
echo 'Max limit is ' $maxlimit
tlimit=$(bc <<< $maxlimit*0.8)
echo 'Treshold limit at 80% ' $tlimit
a=$(lsof | wc -l)
echo 'Current usage ' $a
if [ $(bc <<< "$a > $tlimit") -eq 1 ]
then
        echo 'lsof =' $a 'has exceeded 80% of maximum limit' | /usr/bin/Mail -s "ALERT!!!" "*****@cisco.com"
fi

* * * * * bash /root/vasanth/lsef/script.sh

In the above script, the output is to send a mail to the corresponding Mail ID .

When I run it manually it sends the mail.

But, when it is scheduled in cron, the mail is not being sent.

I cant understand what the problem is. How could I debug it?

Source Link
Vasanth
  • 11
  • 1
  • 2

Sending mail from a script which is run by Crontab

#!/BIN/BASH
# To alert whenever lsof crosses 80%

maxlimit=32000
echo 'Max limit is ' $maxlimit
tlimit=$(bc <<< $maxlimit*0.8)
echo 'Treshold limit at 80% ' $tlimit
a=$(lsof | wc -l)
echo 'Current usage ' $a
if [ $(bc <<< "$a > $tlimit") -eq 1 ]
then
        echo 'lsof =' $a 'has exceeded 80% of maximum limit' | /usr/bin/Mail -s "ALERT!!!" "*****@cisco.com"
fi

* * * * * bash /root/vasanth/lsef/script.sh

In the above script The output is to send mail to the corresponding Mail ID . When I run it manually it sends the mail When it is scheduled in CRONTAB Mail isnt being sent

I cant understand what the problem is........