After installing ssmtp and mailutils, writing to a file with 'echo' tries to send me an email to username@hostname. For example:
Sending mail with mailutils:
echo "Body text here." | mail -s "Subject text here." sendto@email.com
and I use:
echo "log content" > logfile.txt
to write content to a log file.
The problem is that when I want to wite to a log file, I get an deliverable email from Gmail saying username@hostname is unreachable, meaning that it interferes with mailutils.
I this a known issue with mailutils which needs a workaround or fix and how can I approach it?
echo "log content" > logfile.txt
. – Renier Delport Mar 17 '16 at 10:17echo
that overrides the built-inecho
or/bin/echo
? because neither of them send any email - they do not even have the capability to do so...that is not their job, their job is to echo their command line arguments to stdout, and nothing more. – cas Mar 17 '16 at 11:33base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
somehow interfere? for example ifecho "log content" > $base_dir/logfile.txt
? – Renier Delport Mar 17 '16 at 14:29echo
andmailutils
were just irrelevant distractions). It looks like you have a cron job sending the email. BTW, isuser@hostname
literal or have you edited it for anonymity? Check "user"'s crontab, and the script mentioned in the error message -/home/Scripts/logging_script.sh
. as for your base_dir question, no. – cas Mar 17 '16 at 21:30echo "log content"
followed byecho "log content" > logfile.txt
might trigger this behaviour? – Renier Delport Mar 18 '16 at 11:59cron
always emails any job output to the owner of the crontab or the address in theMAILTO
variable, unless that output is redirected to a file (it's not unusual to redirect individual crontab entries to /dev/null) - seeman 5 crontab
.