LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Have the output of the file mailed to you (http://www.linuxquestions.org/questions/linux-newbie-8/have-the-output-of-the-file-mailed-to-you-877618/)

amario26 04-28-2011 09:03 AM

Have the output of the file mailed to you
 
Hi guys,

sorry I am new to this Linux thing and I am unable to figure out how to send the output of a cronjob to me in a mail. so far my cronjob works and it sends the output to a file (which is timestamped) but when it sends me an e-mail it comes blank!

any ideas?

here is the code:

Code:

00 16 * * 1-5 bash /home/amar/RoutineBackupTest.sh > `date +\%d_\%m_\%Y_\%H_\%M`-cron.log 2>&1 && mail -s "Backup Log for `date +\%d_\%m_\%Y_\%H_\%M`" my.email@company.com

AlucardZero 04-28-2011 09:27 AM

(1) You are redirecting all output to date-cron.log, (2) you aren't even trying to pass text to your mail command (&& vs |).

Assuming you want just the email:
Code:

00 16 * * 1-5 bash /home/amar/RoutineBackupTest.sh | mail -s "Backup Log for `date +\%d_\%m_\%Y_\%H_\%M`" my.email@company.com


All times are GMT -5. The time now is 11:26 AM.