LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 09-19-2006, 11:23 AM   #1
hkillen
Member
 
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.

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

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
/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 * * * * myscript.sh >>/somelogdir/myscript.log 2>&1

Where myscript and somelogdir are the names you choose. The above will send any output of myscript.sh 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:

date
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, 08:00 AM   #3
hkillen
Member
 
Registered: Jun 2006
Posts: 41

Original Poster
Rep: Reputation: 15
It Worked!

Thanks for your help!
 
Old 09-20-2006, 09:44 AM   #4
timmeke
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).
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration