1828258 Members
2796 Online
109975 Solutions
New Discussion

cron failing to execute

 
Ravi_8
Honored Contributor

cron failing to execute

Hi,
we have RH 8.0 running clearcase server. I have written some scripts and when I scheduled it using cron (entry has been made in /etc/cron.daily),job is not at all getting executed. any body can help me.
(crond is running)
never give up
29 REPLIES 29
Muthukumar_5
Honored Contributor

Re: cron failing to execute

Did you check with cron log file of /var/log/cron? It will contain execution informations of crond + scripts there.

Try to execute the script with debug mode and check that you are using exit 0 at end.

HTH.
Easy to suggest when don't know about the problem!
Stuart Browne
Honored Contributor

Re: cron failing to execute

'/etc/cron.daily/' is a collection of scripts which gets launched at 04:02am every day.

The files of which are placed in this directory have to be able to be executed on their own (i.e. must have #!/bin/shell or are binaries, and must be 'chmod +x'd).
One long-haired git at your service...
Ravi_8
Honored Contributor

Re: cron failing to execute


Hi,
The log file shows this,

Dec 6 11:01:00 zambezi CROND[2779]: (root) CMD (root run-parts /etc/cron.hourly)
Dec 6 11:47:00 zambezi crond[805]: (*system*) RELOAD (/etc/crontab)
Dec 6 11:47:00 zambezi crond[805]: (tmp.28731) ORPHAN (no passwd entry)
Dec 6 11:47:00 zambezi CROND[3091]: (root) CMD (run-parts /etc/cron.daily)
Dec 6 11:47:02 zambezi anacron[3260]: Updated timestamp for job `cron.daily' to 2004-12-06

I am modifying cron.daily time to suit my requirement.
never give up
Stuart Browne
Honored Contributor

Re: cron failing to execute

I don't like that ORPHAN entry, but..

Do a simple 'ls -l' of '/etc/cron.daily/'.
One long-haired git at your service...
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

did root receive some mail from cron?
Ravi_8
Honored Contributor

Re: cron failing to execute

Hi

these are the files under cron.daily
]$ ll
total 32
lrwxrwxrwx 1 root root 28 Dec 17 2003 00-logwatch -> ../log.d/scripts/logwatch.pl
-rwxr-xr-x 1 root root 135 Jul 2 2002 00webalizer
-rwxr-xr-x 1 root root 276 Aug 28 2002 0anacron
-rwxr-xr-x 1 root root 496 Dec 6 11:54 b4bkup
-rwxr-xr-x 1 root root 51 Jun 24 2002 logrotate
-rwxr-xr-x 1 root root 418 Sep 3 2002 makewhatis.cron
-rwxr-xr-x 1 root root 104 Sep 4 2002 rpm
-rwxr-xr-x 1 root root 137 Apr 23 2004 slocate.cron
-rwxr-xr-x 1 root root 193 Jun 24 2002 tmpwatch


Root is not receiving any mails
never give up
KevinHu_1
Occasional Advisor

Re: cron failing to execute

cron.daily is system's crontab

i prefer execute some scripts with "crontab -e", and determine execute time yourself

good luck
Fred Ruffet
Honored Contributor

Re: cron failing to execute

What is the script you added ?
Can you give output for "ls -l" on linked file ../log.d/scripts/logwatch.pl ?

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

Ravi, can you add some debug output to you "backup" script?
Probbaly script runs but just doesn't do what you want?
xyko_1
Esteemed Contributor

Re: cron failing to execute

Hi Ravi,

are the other daily scripts running ?

I suggest that you put a mail command sendind to you a message when your script starts, as a debug actions like Vitaly Karazik said.

I assume that you have tested your script running it for yourself (not using cron), and that it is doing it's job.

Regards,
Xyko
Ravi_8
Honored Contributor

Re: cron failing to execute

Hi,

I am new to Linux world, worked extensively on HP-UX and AIX. The script used to work on AIX ( scheduled it using cron)but the same script on Linux is not working. Even the simple 'echo' is not working when i scheduled it using crontab. I don't know whether existing scheduled jobs are executing or not.
never give up
xyko_1
Esteemed Contributor

Re: cron failing to execute

Hi Ravi,

try to specify the shell used to run the script. Normaly you don't have to do so on HP-UX nor AIX.
Put a first line in your script like that and try again.

#!/bin/bash

Regards,
Xyko
Ravi_8
Honored Contributor

Re: cron failing to execute

Hi xyko

I have specified the shell and everything.
never give up
Fred Ruffet
Honored Contributor

Re: cron failing to execute

So it may be a porting issue...

Sorry Xyko, but bash shouldn't be used. Try to use /bin/sh instead. It is linked to bash, but, executed through this link, it will act as a posix SH. This will probably be better.

Could you post your shell script here and errors at runtime ? It would help resolving problems.

Another point (when shell will work) is that cron is not setting environment. So you will have to put in cron a wrapper to this shell, first placing env then call your script. Other way is to use "su - user -c job" (even for root) to set env.

Note that preceding post is right. It is more common to use crontab than those system jobs to schedule jobs.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
xyko_1
Esteemed Contributor

Re: cron failing to execute

Hi Fred,
thank's for your comment.

Living and learning with friends.... that's the best part of our job.

regards,
Xyko
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

AFAIK,

if root doesn't receive email with error message from cron - cron job finished without errors.

I've checked cron right now by adding my script
to /etc/cron.daily directory and it works!

My script is:

echo "test" >/tmp/kkk
Fred Ruffet
Honored Contributor

Re: cron failing to execute

Xyko,

Sorry if I'm a bit rude in my posts. I need to progress in english ;-)

Vitaly,

Wait for Ravi to post his script. Apparently it does not work on command line. Echo is working in cron as long as it is implemented in shell. Default PATH for cron jobs is null. "When a crontab command is run, this crontab runs it with /bin/sh and sets up only three environment variables: USER, HOME, and SHELL" (man crontab).

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

Fred, you're right - problems with environment is typical for cron tasks in UNIXes.

A small corection - all scripts under /etc/cron.* dirs have /sbin:/bin:/usr/bin:usr/sbin in PATH.
Ravi_8
Honored Contributor

Re: cron failing to execute

Hi Guys,

here is my script, which will lock all VOB's in the clearcase and stops it, and I have scheduled Veritas to backup all the VOB's.

#!/bin/sh
cleartool lock vob:/vob/adminvob
cleartool lock vob:/vob/testing
cleartool lock vob:/vob/testvob
cleartool lock vob:/vob/rambo
cleartool lock vob:/vob/Fcat
/opt/rational/clearcase/etc/clearcase stop
echo " Clearcase case ready to backup"

pls post your opinions, i will get back to you tomorrow as my wife already calling me home

never give up
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

you should use something like /opt/rational/clearcase/rhat_x86/bin/cleartool

instead of just "cleartool"

BTW, root *should* receive email with error message in your case. Do you have some mail alias for "root"? if no, there is some problem with email.
Fred Ruffet
Honored Contributor

Re: cron failing to execute

Vitaly's right, Use mail or mailx to see root's mail. If there are errors, post them here. But setting path for yout program should be good.
Echo command is exactly the kind of output that should be send by mail as long as there is no redirection.

Vitaly,

Is there any other particularity for those particular crons ? Where to have info on them (man page ?)

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Steven E. Protter
Exalted Contributor

Re: cron failing to execute

If its just some cron jobs and not others, the most common cause is the script is failing on environment variables.

If the script works at the command line and not cron that is almost always the cause.

PATH is most important, but any environment variable wrong can cause the script to silently die in cron.

There is adequate diagnostic help in this thread to resolve the issue. I'd like to see error output.

Good Luck,

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
Vitaly Karasik_1
Honored Contributor

Re: cron failing to execute

Fred, /etc/crontab is setting some environment.
xyko_1
Esteemed Contributor

Re: cron failing to execute

Fred,

you were not rude, don't be afraid of that.

Btw, my english is not good also.



Ravi, to look for root messages is a very good idea. Your mail system is probably misconfigured.

regards for everybody,
xyko