Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-28-2011, 09:03 AM   #1
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:

00 16 * * 1-5 bash /home/amar/ > `date +\%d_\%m_\%Y_\%H_\%M`-cron.log 2>&1 && mail -s "Backup Log for `date +\%d_\%m_\%Y_\%H_\%M`"
Old 04-28-2011, 09:27 AM   #2
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,694

Rep: Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566Reputation: 566
(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:
00 16 * * 1-5 bash /home/amar/ | mail -s "Backup Log for `date +\%d_\%m_\%Y_\%H_\%M`"


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

All times are GMT -5. The time now is 08:46 PM.

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