LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-03-2014, 03:30 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
[RHEL 5] How to find the history of the cron job?


There are some cron job defined under /etc/cron.daily for example. Everyday these cron jobs will do something. I wonder if there is any history or log for those activities.

Or can I extend the cron job to do this?

Last edited by thomas2004ch; 07-03-2014 at 03:33 AM.
 
Old 07-03-2014, 03:36 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

did you check /var/log/cron and /var/log/cron-* for older logs?

Evo2.
 
Old 07-03-2014, 03:48 AM   #3
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Here is what under /etc/cron.daily:
delete-pbv-inet-pdf
zip-and-mv-log

This means there are only two jobs.


And here is what I get from the /var/log/cron:
...
Jul 3 04:02:01 s003ap02-test crond[12950]: (root) CMD (run-parts /etc/cron.daily)
Jul 3 04:10:01 s003ap02-test crond[13323]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:20:01 s003ap02-test crond[13427]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:30:01 s003ap02-test crond[13574]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:40:01 s003ap02-test crond[13727]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:50:01 s003ap02-test crond[13873]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 05:00:01 s003ap02-test crond[14022]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 05:01:01 s003ap02-test crond[14029]: (root) CMD (run-parts /etc/cron.hourly)
...

I understand little what information I can get here.
 
Old 07-03-2014, 04:55 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
You can look at the files in /etc/cron.daily and /etc/cron.hourly. The run-parts is documented at http://man.cx/run-parts%288%29

Normally, the output of any cron job is mailed to the local user. That includes root for these jobs. If there is no output (stdout/stderr) from a job, then there is no email.

The sa1 script is for running the sar (system activity report) utilities for the purpose of collecting general performance data for later use in generating reports.
 
Old 07-03-2014, 05:32 AM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,808

Rep: Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777Reputation: 2777
Cron jobs

When I write my own cron jobs I define a log file and record things to it. The Date-Time stamp (format %Y%m%d-%T ) of the run and exit state (success/failure) if nothing else. Naturally I also have the process trim the log to a certain size to prevent unlimited growth. System and package cron jobs rarely have any logging features.

I use the above techniques because my jobs have to run on a range of systems, often some that have no standard syslog functions. The better way on RHEL is to make use of the standard logging and log rotation utilities. Packages from RHN that define cron jobs normally do so if they log at all.

Cron itself does use syslog, as you discovered. I would check /var/log/messages and /var/log/syslog files for cron entries in addition to the ones you found, but what you have found may be the only record.

Man pages and RHEL online documentation are very good. Other than curiosity (reason enough) why do you ask this question? Have you reason the believe some cron jobs are not running or running improperly, or is it that you want to know what these jobs are doing? Package Log files are often somewhat less than human language. These are clearly designed more for assisting an expert if something goes wrong than for informing the average admin. I would search the documentation for reference to the specific job or process.

Last edited by wpeckham; 07-03-2014 at 05:37 AM.
 
Old 07-03-2014, 08:30 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by thomas2004ch View Post
Here is what under /etc/cron.daily:
delete-pbv-inet-pdf
zip-and-mv-log

This means there are only two jobs.
No. Cron jobs can be defined elsewhere.

Quote:
Originally Posted by thomas2004ch View Post
And here is what I get from the /var/log/cron:
...
Jul 3 04:02:01 s003ap02-test crond[12950]: (root) CMD (run-parts /etc/cron.daily)
Jul 3 04:10:01 s003ap02-test crond[13323]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:20:01 s003ap02-test crond[13427]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:30:01 s003ap02-test crond[13574]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:40:01 s003ap02-test crond[13727]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 04:50:01 s003ap02-test crond[13873]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 05:00:01 s003ap02-test crond[14022]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 3 05:01:01 s003ap02-test crond[14029]: (root) CMD (run-parts /etc/cron.hourly)
...

I understand little what information I can get here.
It's the log showing what cron jobs were run. Isn't that what you asked for?

Evo2.
 
  


Reply


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 to find all the cron job running in a server despites accounts simransab Linux - Newbie 1 12-01-2009 09:53 PM
[SOLVED] Not able to run cron job for non-privileged user in RHEL 5.3 mail4vijay Linux - General 3 11-24-2009 10:18 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
find history of a job killed by "kernel: Out of Memory: Killed process" poulacou Linux - Server 3 09-20-2007 04:24 PM
annoying cron job on find, how to get rid of it feetyouwell Linux - Software 2 06-27-2005 08:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:27 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