LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-2010, 07:09 AM   #1
the182guy
Member
 
Registered: Jan 2009
Posts: 40

Rep: Reputation: 15
Email output of Cron command, sends email but no content?


Using CentOS. I have a cron setup to run this command:

Code:
/var/test.sh | mail -s "Test Cron" mr182@somewhere.com
The email is sent but the output of the script is not in the email body, it's just blank. I know there is some output because there are some echo statements in the script.

I don't want to get an email for all cronjobs, just this one.

Any ideas?

Thanks
 
Old 05-28-2010, 08:20 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
There may be some echoes, but run it without that for now, see if you get any errors; your email there wont email anything on stderr.
 
Old 05-28-2010, 08:38 AM   #3
the182guy
Member
 
Registered: Jan 2009
Posts: 40

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jamescondron View Post
There may be some echoes, but run it without that for now, see if you get any errors; your email there wont email anything on stderr.
Hi mate, there are no errors, I thought it was send the echo statements in the email aswell? Also tried this:

Code:
/var/test.sh 2>&1 && mail -v -s "Cron: test" mr182@somewhere.com
 
Old 05-28-2010, 08:58 AM   #4
the182guy
Member
 
Registered: Jan 2009
Posts: 40

Original Poster
Rep: Reputation: 15
Got it working using this:

Code:
/var/test.sh 2>&1 | mail -v -s "Cron: test" mr182@somewhere.com
 
Old 05-28-2010, 09:52 AM   #5
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Yes, thats because there errors in the cronjob, so it redirects stderr to stdout and etc. etc.
 
  


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
How to configure an email server that sends email to hotmail with Fedora? acarri Linux - Server 5 03-10-2010 02:05 AM
cron job sends email mdg Programming 2 12-26-2009 03:40 AM
Ned to send command output to email Thaidog Programming 2 11-21-2009 11:58 AM
how to make root cron job to send email if there is output mirror51 Linux - Newbie 3 08-12-2009 01:01 AM
POSTIX Sends Hostname in Email carlosinfl Linux - Server 6 01-15-2008 02:13 PM


All times are GMT -5. The time now is 08:09 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration