I do not want to use Cloudwatch want to use shell script for this , Could you please suggest?

Actually i have written a script as below:

But its not alerting me when the EFS is unmounted.

##email subject
subject="EFS is unmounted"
## sending mail to
## send carbon copy to

## Check if EFS is mounted or not
efscommenpart=$(df -kh | grep amazonaws.com | cut -d "." -f4)

## If EFS is unmounted
if [[ "$efscommenpart" -ne amazonaws  ]]


        echo -e "EFS is not mounted" | mailx -s "$subject" -r "$Hostname" -c "$to" "$also_to"

This is urgent...!!!


As the bash scripting guide will tell you, -ne does integer comparison. To compare strings, you'll need to use the != operator instead.


$ var=empty
$ if [[ $var != "amazonews" ]]; then echo Send Email; else echo All Good; fi
Send Email

$ var=amazonews
$ if [[ $var != "amazonews" ]]; then echo Send Email; else echo All Good; fi
All Good

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.