I have a script that redirect the df output to a file and then send it in an email. The mail command is set up as following:
/usr/bin/mail -s "Subject" -r from@nowhere.com toaddress@somewhere.com < /tmp/diskSpace.txt
Everything is working correctly when I run this script as root user but I have a strange behaviour when I run it from the root crontab. In this case the message is delivered but the content of /tmp/diskSpace.txt is attached to the email instead to be the body. I even tried to replicate the root environment running the cron as:
env `cat root-env-saved-to-this-file` /bin/bash mailscript.sh
but nothing changed. Any suggestion or I should just handle this with perl mail libraries ?