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 03-20-2007, 03:33 PM   #1
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, 04:02 PM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quoted from:
man 8 cron
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:
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):
3 * * * * /bin/date && touch /home/somebody/success

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

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

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
Old 03-22-2007, 01:01 PM   #4
LQ Newbie
Registered: Mar 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks both, I'll check out your suggestions.
Old 03-22-2007, 02:08 PM   #5
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.



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

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