How to detect and fix why crontab job is not executed?


Login or Register to Reply

 
Thread Tools Search this Thread
# 8  
Old 2 Weeks Ago
I know it is unlikely, but has anyone checked whether or not the server is running at 6am on the day(s) when the cron job doesn't run? If there is some kind of daily maintenance operation that takes the server out of normal multi-user mode during that timeframe, cron jobs that were missed while not in multi-user mode will not be started if the system comes back up to normal multi-user mode after the job's scheduled start time.
This User Gave Thanks to Don Cragun For This Post:
RudiC (2 Weeks Ago)
# 9  
Old 2 Weeks Ago
Quote:
Originally Posted by Don Cragun
I know it is unlikely, but has anyone checked whether or not the server is running at 6am on the day(s) when the cron job doesn't run? If there is some kind of daily maintenance operation that takes the server out of normal multi-user mode during that timeframe, cron jobs that were missed while not in multi-user mode will not be started if the system comes back up to normal multi-user mode after the job's scheduled start time.
Hi Don,

Thanks for your answer.

For now with the help of bukuni and RudiC I've set the cron in this way

Code:
  # crontab -l
0 6 * * * /path/to/scripts/script1.sh > /root/CronLog/cronlog.log 2> /root/CronLog/cronlog.err

The issue is that the cron job has failed every day of the week.

Do you know how to check if the source server was running a maintenance operation or something else when the cron job failed?

The source server model/version is

SunOS Generic_118833-22 sun4u sparc SUNW,Sun-Fire-V245

Thanks
# 10  
Old 2 Weeks Ago
Did you add the set -vx to the script so it prints useful info?
For the server maintenance, you check the server system logs. You could also search for the relevant cron entries there.
# 11  
Old 2 Weeks Ago
You have got Solaris. (BTW a very old Solaris 10, certainly never updated.)
Solaris /usr/bin/date has no -d option. The trailing -d is ignored! (An initial -d would give an error).
Either you have got GNU date installed, then please add the path to it, usually /usr/local/bin/date or /usr/sfw/bin/date or /opt/csw/bin/date
Or install GNU date.
Or try the TZ trick:
Code:
dyear=`TZ=$TZ+24 /usr/bin/date +'%Y'`
dmonth=`TZ=$TZ+24 /usr/bin/date +'%b'`
ddate=`TZ=$TZ+24 /usr/bin/date +%Y-%m-%d`

# 12  
Old 2 Weeks Ago
Quote:
Originally Posted by RudiC
Did you add the set -vx to the script so it prints useful info?
For the server maintenance, you check the server system logs. You could also search for the relevant cron entries there.
Hi RudyC. Yes, I've added set -vx. So I'll need to check by tommorow what appears in those logs. Thanks for the help.

--- Post updated at 02:41 PM ---

Quote:
Originally Posted by MadeInGermany
You have got Solaris. (BTW a very old Solaris 10, certainly never updated.)
Solaris /usr/bin/date has no -d option. The trailing -d is ignored! (An initial -d would give an error).
Either you have got GNU date installed, then please add the path to it, usually /usr/local/bin/date or /usr/sfw/bin/date or /opt/csw/bin/date
Or install GNU date.
Or try the TZ trick:
Code:
dyear=`TZ=$TZ+24 /usr/bin/date +'%Y'`
dmonth=`TZ=$TZ+24 /usr/bin/date +'%b'`
ddate=`TZ=$TZ+24 /usr/bin/date +%Y-%m-%d`

Thanks for your suggestions, but since I get the date, year, month in destination server (CentOS) where the cron job is defined, then I don't have issues with date command.

The question about SunOS was more oriented how to know, if possible, if it runs some maintenance operation in a timeframe that includes the hour when the cron is configured on CentOS server (04:00 or 06:00 am).

If not I'll wait tommorow if something appears in log.

Thanks again.
# 13  
Old 2 Weeks Ago
I don't remember the name of the log file that would contain the information about when the system changes states, but there has to be one. And, as has already been stated, look for cron's log file as well.

A quick and simple check would be to see what output you get from the command:
Code:
uptime

when run on that server. If it says the system has been up longer than when your last 6am cron job was skipped, that isn't your problem.
# 14  
Old 2 Weeks Ago
Quote:
Originally Posted by Don Cragun
I don't remember the name of the log file that would contain the information about when the system changes states, but there has to be one. And, as has already been stated, look for cron's log file as well.

A quick and simple check would be to see what output you get from the command:
Code:
uptime

when run on that server. If it says the system has been up longer than when your last 6am cron job was skipped, that isn't your problem.
Thanks for your answer Don.

On SunOS server where I copy the files from the uptime command gives this output.

Code:
# uptime
  4:28pm  up 839 day(s),  5:42,  1 user,  load average: 0.08, 0.07, 0.07

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Crontab job is not working ipfreak UNIX for Dummies Questions & Answers 6 03-06-2016 04:39 AM
Detect changes to crontab Junaid Subhani Shell Programming and Scripting 1 08-28-2013 05:15 AM
Crontab Job Syntax JolietJake Shell Programming and Scripting 1 06-28-2013 09:43 PM
Cron job executed at wrong time moxnos UNIX for Dummies Questions & Answers 4 12-07-2012 12:45 PM
crontab job not executed with variables turki_00 Shell Programming and Scripting 4 10-04-2012 09:01 AM
Users who desire to have their .profile executed must explicitly do so in the crontab entry. Why? thulasidharan2k Shell Programming and Scripting 1 07-29-2011 02:36 AM
Schedule a job using Crontab jatanig Shell Programming and Scripting 1 03-15-2010 09:45 AM
Log files to view job executed in Autosys -- Help ASAP sakal_woman UNIX and Linux Applications 1 05-22-2009 07:47 PM
Script errors out only when its executed via job mrx1350 Shell Programming and Scripting 6 03-26-2009 01:50 PM
Routine doesn't give output when executed in crontab SharkM Shell Programming and Scripting 1 02-12-2008 09:56 AM
Help with a crontab job!!! kumarsaravana_s Shell Programming and Scripting 4 03-28-2007 04:02 AM
bash scripting cannot executed in crontab jimmbp Shell Programming and Scripting 6 11-11-2005 10:23 AM
crontab job Moe UNIX for Dummies Questions & Answers 3 11-02-2005 04:17 PM
Shell script doesn't get executed using crontab radhika Shell Programming and Scripting 11 06-09-2005 04:28 PM
ant not being executed as cron job kingfinny Shell Programming and Scripting 5 11-12-2004 12:11 PM