LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-20-2007, 02:33 PM   #1
CJKing
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
Question how do I know if a cron job ran OK ?


I'm new to Linux so sorry if this is a stupid question but......when I set up a cron job using crontab -e, is there a way to find out if crond actually executed the command OK (I mean apart from looking at the output file, if one was used). I guess I'm asking if there is a crond error messages file somewhere.....
 
Old 03-20-2007, 03:02 PM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quoted from:
Code:
man 8 cron
Quote:
cron logs its action to the syslog facility ’cron’, and logging may be controlled using the standard syslogd(8) facility.
That seems to tell that cron uses the system logger to create it's logs. The relevant file, I guess, is /var/log/syslog which you need to go trough to see what (possible error) messages cron has produced. Read the man page I referred to for more information, and possibly any syslog man pages:
Code:
man -k syslog
for more information.

The other option is to make the cron command create somekind of output to tell if it succeeded; for example the below line would run date and if it succeeds, create (an empty) file called success to /home/somebody/ (and if I'm right, failed date causes the file not to be created..and if the file already exists, it's time stamp is updated):
Code:
3 * * * * /bin/date && touch /home/somebody/success

Last edited by b0uncer; 03-20-2007 at 03:05 PM.
 
Old 03-20-2007, 03:24 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
You can also set this in your crontab:

MAILTO=user@somedomain.com

That's if you don't have any STDOUT or STDERR redirects. Or just simply pipe it to mail someone upon completion, kind of like b0uncer's suggestion to touch a file, etc.

3 * * * * /bin/date | mail -s SUCCESS user@somedomain.com
 
Old 03-22-2007, 12:01 PM   #4
CJKing
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks both, I'll check out your suggestions.
 
Old 03-22-2007, 01:08 PM   #5
mether
Member
 
Registered: Mar 2007
Distribution: RHEL, Fedora, Open Suse
Posts: 151

Rep: Reputation: 31
I am not sure abt what distro u using, its RHEL or fedora then you can collec logs in /var/log/cron. Although the mail thins is the best bet.
 
  


Reply

Tags
crond


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
cron job somsahi Linux - Software 9 10-05-2006 02:19 PM
cron job wbatzle Linux - Newbie 2 07-12-2005 04:19 PM
CRON Job tommytomato Fedora 12 09-13-2004 12:38 AM
cron job working2hard Programming 6 07-28-2004 09:12 PM
Cron job T-Rex Linux - Newbie 1 09-26-2001 11:28 AM


All times are GMT -5. The time now is 08:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration