Page 1 of 1

email from cron job failing

Posted: Wed Mar 23, 2016 8:50 pm
by badams_ios
I have a very simple script that moves files from one location to another once a week. I'd like to send myself an email letting me know it completed successfully.

Here's what I have:
0 1 * * Mon ~/TB/scripts/movefiles mail -s "CronJob is run successfully" me@mine.com

Without the mail command, the script works fine. But no email is sent.

I've tried adding: > /home/me/Documents/results.log 2>&1 both before and after the mail command to see what's going on,but that doesn't work either.

Do I have to install a sendmail program?

Re: email from cron job failing

Posted: Thu Mar 24, 2016 7:30 am
by amethyst_igor
badams_ios wrote:I have a very simple script that moves files from one location to another once a week. I'd like to send myself an email letting me know it completed successfully.

Here's what I have:
0 1 * * Mon ~/TB/scripts/movefiles mail -s "CronJob is run successfully" me@mine.com

Without the mail command, the script works fine. But no email is sent.

I've tried adding: > /home/me/Documents/results.log 2>&1 both before and after the mail command to see what's going on,but that doesn't work either.

Do I have to install a sendmail program?
I find it helpful to run things from the command line to get feedback from Linux or Windows. Let's see what happens when I run mail.

Code: Select all

elflord@elflord-desktop / $ mail
The program 'mail' is currently not installed. You can install it by typing:
sudo apt-get install mailutils
elflord@elflord-desktop / $
So there you have it.