Any way to log start and end time of cron jobs in RHEL 5 and up?

Posted on 2014-07-25
Medium Priority
Last Modified: 2014-07-29
I would like cron to log start and end times for each job run. I know how to do this in DEBIAN but not red hat.
Question by:Shawn3
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
LVL 13

Expert Comment

ID: 40220089
For example,
*/10  *     *  5,7,11  *    root command1
0     9-18  *  *       1-5  root command2
These lines will run command1 every ten minutes during May, July and November, and command2 once an hour during the working day (09:00 to 18:00) Monday to Friday.


Author Comment

ID: 40220170
Thanks Duncan, but I know how to use cron. I need to know how to get a start and end time for each of the jobs. Currently, cron logs start time and thats it.

LVL 13

Expert Comment

ID: 40220178
Why not make an example to the experts, other experts will come to solve issue
based your example ? otherwise, they don't know what you need

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

LVL 38

Accepted Solution

Gerwin Jansen, EE MVE earned 1500 total points
ID: 40220586
Simplest is to write wrapper commands (or script)

The wrapper logs start date/time with the cron script's name, calls the cron script and logs end date/time.

Easiest if you give every cron script it's own log file name.

For example:

00 10 * * * echo "`date` Start of cron1" >> /home/user/cronjob1.log ; /home/user/cronjob1 ;  echo "`date` End of cron1" >> /home/user/cronjob1.log 

Open in new window


Author Comment

ID: 40224305
Thanks Gerwin. I have hundreds of cron jobs. I think this is a great solution, but was hoping there was a system level logging setting that I could enable.

Author Closing Comment

ID: 40224311
This will work, but I'm looking for system level logging for all cron jobs if possible.
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40224522
You could try setting higher log level for cron in /etc/sysconfig/crond :


and then restarting cron : sudo service cron restart

My preference is the solution you've chosen so you can easily keep track of all jobs in one place. And the cron log itself is not accessible for users.

Author Comment

ID: 40224616
I will try that...but thought it was only for debian based distros...

Tried the crondargs, but it throws an error in RHEL. I think that param is for Debian based distros. Thanks though!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question