1836612 Members
3909 Online
110102 Solutions
New Discussion

Cron Problem

 
Vibhor Kumar Agarwal
Esteemed Contributor

Cron Problem

Hi,

I have a cron entry in the crontab file which used to run about dozen of days back.

Now suddenly it has stoped to run.

Two things that i investigated:
The cron log shows that it has run successfuly.
There is no problem with the entry, as simply copying-pasting it in shell runs it.

Thanks
Vibhor Kumar Agarwal
27 REPLIES 27
Muthukumar_5
Honored Contributor

Re: Cron Problem

when it was running at last. what is that time period for that job? can you post that crontab entry and log information for last execution here.

--
Muthu
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: Cron Problem

Hello,

What was the expected result? How did you conclude that it wasn't working ?

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: Cron Problem

Hi Vibhor,

Any ENV variables changed ??

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Steven E. Protter
Exalted Contributor

Re: Cron Problem

Shalom Vibhor,

Seems to me that cron may have failed to run.

ps -ef | grep cron

If you don't hae a cron daemon running,

/sbin/init.d/cron start

Its also possible that there was a bad entry added to the crontab table.

crontab -l

look for something new and remove it.

If you have recently upgraded your system to trusted, this is a possible impact.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

It doesn't give any error, neither does it report anything.

The entry is :

01 01 * * 2 script parameter

In the log its:
CMD: script parameter
User_name 10246 c Tue Feb 14 01:01:00 2006

Anything else
Vibhor Kumar Agarwal
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

ps -ef | grep cron

root 207 1 0 Nov 17 ? 9:10 /usr/sbin/cron
Vibhor Kumar Agarwal
Muthukumar_5
Honored Contributor

Re: Cron Problem

It is working properly,

01 01 * * 2 script parameter

In the log its:
CMD: script parameter
User_name 10246 c Tue Feb 14 01:01:00 2006

It has to execute on every tuesday in the week at 01 minute of 01 hour.

It is done. It will execute script by next tuesday as,

Feb 21 01:01:00 2006 time.

what is the problem you are seeing with this.

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Cron Problem

change this line of

01 01 * * 2 script parameter

to suite your requirement of execution time (If you need). Please tell if you want to change time of execution of this script.

--
Muthu
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

If it had run, then the output would have been visible to me.

The script copies something, which isn't happening.
The script is error free as simply running:

script parameter
works fine and this used to run via cron also some days back.

That's what i am not able to find out.
Vibhor Kumar Agarwal
Arunvijai_4
Honored Contributor

Re: Cron Problem

Vaibhav,

It has executed properly. what was the result of the script ? How did you its not working ?

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Cron Problem

Try this:


xx xx * * 2 script parameter 1>/tmp/test.log 2>&1


change xx xx time and hour to now. Like,

0 15 in india. Change to near coming time and update the change.

what you are getting in /tmp/test.log file?

--
Muthu
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

Thats is what the time i require.

Because this cron is running in US and i need to access the thing in India.
Vibhor Kumar Agarwal
Arunvijai_4
Honored Contributor

Re: Cron Problem

You can just add another crontab entry to test the things up. Whether the server in US or India, it doesnt matter with a telnet/ssh session.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Cron Problem

Can you give this by command line execution?

script parameter 1>/tmp/test.log 2>&1

and,

what is the full syntax you are using in command like with script name and parameter.

--
Muthu
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

The syntax is the one which i have provided

x x x x x /absolute_path parameter

I will have to do some work to add a new entry in that machine.
Will update you when its done.

Thanks
Vibhor Kumar Agarwal
Pete Randall
Outstanding Contributor

Re: Cron Problem

Vibhor,

The cron log should show both the start and completion enties for your job, like this:

> CMD: /apps/bin/wb/checkweb.ksh
> informix 7818 c Fri Feb 10 13:08:00 EST 2006
< informix 7818 c Fri Feb 10 13:08:00 EST 2006

Does you log contain an entry indicating the completion?


Pete

Pete
Pete Randall
Outstanding Contributor

Re: Cron Problem

Sorry . . . . . "your log".


Pete

Pete
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

No,

It contains only one entry.
That means it hasn't run.

Now the question comes, WHY?
Vibhor Kumar Agarwal
Pete Randall
Outstanding Contributor

Re: Cron Problem

If it only contains one entry, then the job started but has not completed. If you run "ps -ef |grep YOUR_SCRIPT", does it return anything?


Pete

Pete
Tonya Underwood
Regular Advisor

Re: Cron Problem

Are there other cron entries that are running? I'm assuming not...

If someone has edited crontab with "vi" instead of crontab -e, cron will get confused. Stop cron, edit crontab the correct way (crontab -e), save your changes even if you haven't made any... restart cron.

Tonya

Mohammad Arif Rahim
New Member

Re: Cron Problem

I had a similar problem, when I was trying to run a bash script (#!/bin/bash) in a sh (/bin/sh) environment (Solaris) using corn. Running the script from cli was also working but not from corn. So I had to change the shell to bash and it worked.

Hope it helps. Any explanation or way around would be greate.
Bill Hassell
Honored Contributor

Re: Cron Problem

First, make sure you have specified the interpreter to use as line #1. If you are using the POSIX shell, it would look like this:

#!/usr/bin/sh

Then edit your script to trace all the steps by adding set -x as in:

#!/usr/bin/sh
set -x

Now you won't have to guess what happened. The result of this script's trace will go to the email for the user running this script.

It is very common for a script to fail in cron but run OK in a login shell. The trace will tell you why (cron has a very limited environment). Most likely there are missing variables in your script's environment.


Bill Hassell, sysadmin
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Cron Problem

There is no problem with the environment as that script used to run a couple of weeks back and it has not changed since then.

Not a problem with the cron file also as many other entries run in the same cron file.

Now what do i do
Vibhor Kumar Agarwal
Kevin Lai_1
Occasional Advisor

Re: Cron Problem

Same problems I faced.

It only happened when I switched from trusted mode to non-trusted mode, and switches it back few times.

But i believe it is something to do with secure mode.

Check the root mail.

"Cron: Your job did not contain a valid audit ID"

This may be the problem.

From past article, this may help:

1. Run tsconvert -p
This will build a file /usr/spool/cron/.cronaids with the data
the system needs

2. Then restart cron.
/sbin/init.d/cron stop
/sbin/init.d/cron start