LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 04-28-2011, 10:03 AM   #1
amario26
LQ Newbie
 
Registered: Apr 2011
Posts: 11

Rep: Reputation: 0
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
 
Old 04-28-2011, 10:27 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,650

Rep: Reputation: 525Reputation: 525Reputation: 525Reputation: 525Reputation: 525Reputation: 525
(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
 
  


Reply

Tags
crontab, mail


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
using grep to output non-matches into output file binny959 Linux - General 5 12-25-2010 12:20 AM
Getting cron result mailed back Swakoo Linux - General 3 08-05-2008 04:21 AM
getting updated threads e-mailed selassie irie Linux - Newbie 2 07-04-2004 12:08 PM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 08:17 PM
Spammer gets junk mailed acid_kewpie General 8 01-04-2003 11:03 AM


All times are GMT -5. The time now is 07:09 PM.

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