Welcome to the most active Linux Forum on the web.
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 09-19-2006, 12:23 PM   #1
Registered: Jun 2006
Posts: 41

Rep: Reputation: 15
Cron log

I set up a cron job and want to prove to my professor that it is working. Is there a log file that records that it actually took place?

I'm looking in the /var/log/cron file and it does not seem to have recorded it, although I know it took place.

Old 09-19-2006, 02:23 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,821
Blog Entries: 15

Rep: Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664
/var/log/cronlog should show if the cron job was initiated but it won't give you any details of what that job did. That is to say it is simply a log for cron scheduling not for the jobs themselves.

When creating a job you want to get better logging for you should just add it to the crontab with redirect statements:

1 * * * * >>/somelogdir/myscript.log 2>&1

Where myscript and somelogdir are the names you choose. The above will send any output of to somelogdir/myscript.log and also redirect any errors to that same log. Of course if the script had no output or errors you wouldn't see anything in the log. You can modify the script by doing things like:

echo "Now running something"

These statements would display the screen when run from the command line but when run from cron (using the above redirect) would go to the logfile you'd created.
Old 09-20-2006, 09:00 AM   #3
Registered: Jun 2006
Posts: 41

Original Poster
Rep: Reputation: 15
It Worked!

Thanks for your help!
Old 09-20-2006, 10:44 AM   #4
Senior Member
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Alternatively, if you have a MTA (mail transport agent) like sendmail or postfix running, you can make
cron mail the output and error messages back to either the user that submitted the cron jobs (default) or to
a random mail address (by adding "MAILTO=someone@somewhere" at the top of the crontab settings).


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
How can I configure the cron log? raybcher Linux - Software 1 12-13-2005 04:35 PM
Does cron have a log I can read? ivj Linux - Software 2 08-18-2005 07:23 PM
cron log empty plisken Slackware 2 11-17-2004 10:00 AM
Can't get Cron to log anything t3___ Linux - Newbie 3 05-19-2004 11:14 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 03:30 PM > Forums > Linux Forums > Linux - Newbie

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