LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-28-2015, 03:29 AM   #1
LYC
Member
 
Registered: Jan 2014
Posts: 109

Rep: Reputation: Disabled
script to check cron jobs


Hi,

What to lookup to verify a cron job has run successfully and failed if a script is to be written?

Thanks in advance.
 
Old 08-28-2015, 04:03 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
usually the job has its own log, you need to check it
 
Old 08-28-2015, 04:16 AM   #3
LYC
Member
 
Registered: Jan 2014
Posts: 109

Original Poster
Rep: Reputation: Disabled
Hi,

Due to my limited knowledge, I can only find the cron log in /var/log/cron. There is a single line that indicating the status of the job but needs to be interpreted. There is also no info on how long the cron job has been run.
 
Old 08-28-2015, 04:35 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
I mean the job itself should write its own logfile, it is not about the log of cron. If your job has no such functionality you can add a wrapper script like this to do that:
Code:
LOGFILE=<this is the name/path of the logfile>
echo "starting job JOBNAME" >> $LOGFILE
date >> $LOGFILE
<execute the original job>
echo "job completed"
date >> $LOGFILE
 
Old 08-28-2015, 04:38 AM   #5
LYC
Member
 
Registered: Jan 2014
Posts: 109

Original Poster
Rep: Reputation: Disabled
Hi,

Correct me that there is no centralised mechanism to track?

Each user has to be responsible to track their cron job?
 
Old 08-28-2015, 07:02 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
cron itself does not take care about the jobs executed.
but may send email about execution
 
Old 08-28-2015, 07:41 AM   #7
LYC
Member
 
Registered: Jan 2014
Posts: 109

Original Poster
Rep: Reputation: Disabled
Hi,

Could you advise how to configure cron to send out mail about execution?
 
Old 08-28-2015, 07:59 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
http://www.nixtutor.com/linux/sendin...-through-cron/
 
  


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
How to check if cron jobs are working? kavyashree A P Linux - Server 2 03-20-2013 04:00 AM
Where are cron jobs located when not under /var/spool/cron/root? NotionCommotion Linux - Newbie 6 09-07-2012 07:33 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
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
Cron Jobs christo512 Linux - Software 1 02-09-2006 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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