You receive the mail any time the cron command has some output (stdout or stderr).
The message "Null message body; hope that's ok" is a warning from the mailx
command. The following modification will suppress all the warnings from mailx:
00 16 * * * /path/script.sh 2> /dev/null | mailx name@domain.com > /dev/null 2>&1
Notes:
- Be aware that if there is any error sending the email, you will not get any report about it.
- Are you sure the stderr of
script.sh
shouldn't be mailed too? If yes, use2>&1
instead of2> /dev/null
.