Cron automatically send output of command to me, therefore it's useless to use `mail`.
But your post was inspiration for me, so I made script:
Code:
#!/bin/sh
output=$(some_command)
output1=$(some_command)
output2=$(/usr/sbin/service nginx reload)
exit_status=$?
if [ "$exit_status" -ne 0 ]; then
echo "error in reload, check it"
echo $output
echo $output1
echo $output2
fi
I need to test it, but I hope I'm close to achieve my goal.
If you have some remarks, write it!