How to configure in crontab with condition statement for checks

Posted by chz on Super User See other posts from Super User or by chz
Published on 2013-10-28T08:39:56Z Indexed on 2013/10/28 9:56 UTC
Read the original article Hit count: 174

Filed under:
|
|
|

We like to monitor the NAS storage mounted on a linux box. We only like to be notified via mail when the usage exceeds a certain number say 80. We have only seen in linux books where most of them are calling shell scripts at certain times.

How do we write inside crontab to only mail us if it exceeds 80 ?

Usual eg
2 2 * * * /home/someUser/script.sh 2>&1 | mail [email protected]

Looking for solution like below

2 2 * * * if [ someNumber > "80" ] ; then /home/someUser/script.sh | mail [email protected]

Sincerely

© Super User or respective owner

Related posts about linux

Related posts about bash