Visit Jeremy's Blog.
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 10-18-2005, 03:03 PM   #1
Registered: Oct 2005
Location: New London, CT USA
Distribution: Ubuntu 7.04
Posts: 49

Rep: Reputation: 15
cron output

First let me say that I have read the man and info pages and also searched on a few Internet sites, but I so far have not been able to find an answer.

I am attempting to ensure that I have configured a cron job correctly. First I attempted the command in a terminal, it worked. Then I created a bash script and copied it into cron.hourly.

What I want is to get some output from crontab to verify that the job went OK. I was able to get an output by changing the "MAILTO=" statement in crontab to mail the result to me. That was unsuccessful until I changed the redirection to /dev/null to a file in my home directory.

After that I was able to get output messages that pointed out some problems with my cron job. I have corrected the problems, but I have not had any feedback since.

So my question: does crontab only give output messages if there is a problem? Can I infer from the lack of output that my job went OK?

Old 10-18-2005, 03:55 PM   #2
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Cron only sends mail if there's output. Regardless of whether there are problems. The cron man page says,
When executing commands, any output is mailed to the owner of the
crontab (or to the user named in the MAILTO environment variable in the crontab,
if such exists).
But you read that.
To make sure there's always some output, put a line like "echo Hurray" at the end of your script. When you are sure all works as intended, take it out again.

You say changing MAILTO gave you output but was unsuccessful? I guess you initially redirected output (and errors) from the commands to /dev/null. So there was no output to mail. Once you leave output alone, mailing matters. If you don't set MAILTO, it will go to your user name on the machine where cron runs. Unless mail is locally configured to send it elsewhere, you can read your mail by typing 'mail' on the machine where cron ran.

You may want to elaborate, or tell us what you are trying to do.
Old 10-18-2005, 03:56 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
No, cron will produce output by default.

It does, however, only use ONE means of doing so,
that is a) either e-Mail or b) output to stdout. If there's
any redirection mail won't happen, it it's to /dev/null
you won't see anything ever.

Old 10-18-2005, 07:11 PM   #4
Registered: Oct 2005
Location: New London, CT USA
Distribution: Ubuntu 7.04
Posts: 49

Original Poster
Rep: Reputation: 15
Thanks guys! I ended up redirecting "$?" to a file in my home and determined that way that all was well.


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
Can the output of cron daemon be sent via other smtp hamish Linux - Software 0 09-02-2005 08:28 AM
Cron output to a file Temujin_12 Linux - General 5 02-23-2005 01:52 PM
Can not send cron output to the screen tryingHarder Linux - Newbie 3 09-26-2004 10:11 PM
cron output? sk8guitar Linux - General 4 08-15-2003 01:55 PM
Understanding CRON output lhoff Linux - General 1 05-19-2003 01:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:41 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