email from cron job failing

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
badams_ios
Level 2
Level 2
Posts: 71
Joined: Tue Jun 18, 2013 7:55 pm

email from cron job failing

Post by badams_ios » Wed Mar 23, 2016 8:50 pm

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?
Clewless

Lenovo ThinkServer
Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz
20 GB RAM
3 TB WD Black, hardware raid 5 - /home
Nvidia GeForce GT 220
32" TV
In the Man Cave :)


Mint Mate 17.1

Media Center, image and video editing

User avatar
amethyst_igor
Level 3
Level 3
Posts: 143
Joined: Thu Feb 25, 2016 9:15 pm
Location: State of Euphoria
Contact:

Re: email from cron job failing

Post by amethyst_igor » Thu Mar 24, 2016 7:30 am

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.
I run both Windows 10 and Linux Mint 18 in dual boot with two SSDs and have other rigs running various versions of Linux. My blog.

Post Reply

Return to “Newbie Questions”