LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-28-2013, 02:14 AM   #1
FortressMvelez
Member
 
Registered: May 2013
Location: Bronx, New York
Posts: 40

Rep: Reputation: Disabled
Cron Job not sending E-mails


Hello,

I have been trying to set up a cron job that sends me an e-mail with a subject line so I know the cron job did run.

I was looking the information from the following:

http://www.linuxquestions.org/questi...n-jobs-886164/

I did what the post said but I never got the e-mail and I checked the spam folder and nothing.

Here is the way I set up the cron job in crontab -e:

MAILTO=emailaddress@gmail.com?subject=Maldet Updated!!
* 1 * * 0 /usr/local/sbin/maldet -u

I set it up for different times to see if it was running and to keep an eye on my e-mail but I never get anything and I'm not sure if I am missing something which is why it is not running or where else to check to see if it ran or not because I never get the e-mail.

Thanks for the help in advance!
 
Old 05-28-2013, 03:20 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
MAILTO can ONLY be an address.
Used by cron to report an error if a cronjob fails.
The default is usually the job owner (or root).

If you want to send an email, ignore that and use an example from here http://stackoverflow.com/questions/2...-mailx-command

cron howto http://www.adminschoice.com/crontab-quick-reference

You probably don't want to send an email every minute ...

Note also that places like google, yahoo etc often won't accept emails from dynamic IPs because of the amt of SPAM that comes from such systems.
If you want to pass an email out, you may have to go via your ISP's mailservers, to get around that problem.
 
Old 05-28-2013, 09:22 AM   #3
FortressMvelez
Member
 
Registered: May 2013
Location: Bronx, New York
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hello,

Thank you for your reply! The information you have provided was very helpful in understanding how this works! So, from what I read you can use mailx to send out the e-mail as I wanted by using the following command:

echo "something" | mailx -s "subject" recipient@somewhere.com

Would this go before the cron job or next to it? For example:

echo "something" | mailx -s "subject" recipient@somewhere.com
* 1 * * 0 /usr/local/sbin/maldet -u

OR

* 1 * * 0 /usr/local/sbin/maldet -u | echo "something" | mailx -s "subject" recipient@somewhere.com

OR

* 1 * * 0 /usr/local/sbin/maldet -u > echo "something" | mailx -s "subject" recipient@somewhere.com

I think if I can get this one part clear everything would work out perfectly with the information you have provided me!

Thanks!!!
 
Old 05-29-2013, 01:23 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Depends what maldet does, but you could try
Code:
 * 1 * * 0 (/usr/local/sbin/maldet -u )| mailx -s "subject" recipient@somewhere.com
You should test your ideas from the cli first (ie not within cron) to see if they work, then add to cron.

Last edited by chrism01; 06-02-2013 at 10:25 PM. Reason: typo
 
Old 06-02-2013, 09:42 PM   #5
FortressMvelez
Member
 
Registered: May 2013
Location: Bronx, New York
Posts: 40

Original Poster
Rep: Reputation: Disabled
Thanks!!!

Hey, did what you told me in your previous reply and it worked perfect! Thank you so much for your help!!!!

Quote:
Originally Posted by chrism01 View Post
Depends what maldet does, but you could try
Code:
 * 1 * * 0 (/usr/local/sbin/maldet -u )| mailx -s "subject" recipient@somewhere.com
You should test your ides from the cli first (ie not within cron) to see if they work, then add to cron.
 
Old 06-02-2013, 10:26 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Glad to help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"sending mails through cron jobs: deepthi.deepu Linux - Server 1 06-14-2011 06:05 AM
Debian/Lenny - user cron jobs sending status e-mails garydale Linux - Server 4 09-04-2009 01:54 PM
FTP cron job seems to be sending OLD data dagalicous Linux - General 9 02-28-2006 03:50 AM
delete mails thru cron job massoo Linux - General 0 01-12-2005 03:19 AM


All times are GMT -5. The time now is 03:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration