LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-16-2009, 05:28 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Question how can we know whether a Cron job has been executed or not ??


Hey,

Is there some way or rather some command which displays some info about the executed cron jobs.


When we run a cron job, logs of it are generated in /var/log/cron
For e.g. we have a cron job
Code:
	[root@Linux]# crontab -l
		      03	12	*	*	*	date > /tmp/abcd
				 
	[root@Linux]# tail -1f /var/log/cron
		      Apr 16 12:03:01 GCESPROUXUHP02 crond[29394]: (root) CMD (date > /tmp/abcd)

Is there some other way to find out executed cron jobs ? Actually, this was asked to me in a interview. I had no answer other than this.




I suggested we could modify the cron job slightly as
Code:
03	12	*	*	*	date > /tmp/abcd 1>/tmp/cron_logs
Doing this, we can see whether the job has executed or not. But, they were looking for some other answer.
 
Old 04-16-2009, 05:32 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
When there is a problem with the cron, you will recieve a mail from the system.
So, no mail, no problem, cron worked OK
 
Old 04-16-2009, 05:59 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Thanks Repo, I will keep this in mind.
 
Old 04-16-2009, 08:14 AM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
You can also check /var/log/cron.
 
Old 04-16-2009, 08:30 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by anomie View Post
You can also check /var/log/cron.
Yeah, as mentioned in my post, I know that it shows in /var/log/cron But I wanted to know that does executed jobs get stored in some file
OR
is there some way (like some command) out to find all executed cron jobs other than /var/log/cron
 
Old 04-17-2009, 01:45 PM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
If it's important to confirm that certain cronjobs (or all cronjobs) are running, echo something to stdout in them, e.g.:

Code:
echo "Running ${0}..."
By default, stdout will go to the mailbox of the user the cronjob is running as.
 
Old 04-17-2009, 01:49 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
And, actually, in your simplistic example (from the first post) you could just check the value of /tmp/abcd.
 
  


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
mencoder fails when executed by cron Maestro485 Linux - Software 7 09-14-2011 09:01 PM
script not executed by cron.daily hopefull Linux - Newbie 6 01-17-2009 09:54 AM
Cron jobs are not getting executed sharu99 Programming 17 11-04-2008 12:04 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Specific Crontab Job is not executed . Itsik Harel Linux - Server 1 03-11-2007 09:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:12 PM.

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