LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Email output of Cron command, sends email but no content? (https://www.linuxquestions.org/questions/linux-newbie-8/email-output-of-cron-command-sends-email-but-no-content-810676/)

the182guy 05-28-2010 07:09 AM

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

jamescondron 05-28-2010 08:20 AM

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.

the182guy 05-28-2010 08:38 AM

Quote:

Originally Posted by jamescondron (Post 3984168)
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

the182guy 05-28-2010 08:58 AM

Got it working using this:

Code:

/var/test.sh 2>&1 | mail -v -s "Cron: test" mr182@somewhere.com

jamescondron 05-28-2010 09:52 AM

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


All times are GMT -5. The time now is 04:34 AM.