Operating System - Linux
1753753 Members
4962 Online
108799 Solutions
New Discussion юеВ

Re: Cron Job Executing Script but Command not Working

 
Chad Brindley
Regular Advisor

Cron Job Executing Script but Command not Working

Hi,

I scheduled a cron job through SAM but it is not working.

The contents of the script are as attached.

Looking at the cron log it is executing the script and some features of it are working apart from the execution of the omnimm commands and I cannot understand why? The deletion of log files and emailing contents of new log files is working okay but the omnimm -repository_update does not seem to be hitting data protector at all. If I execute manually it is fine.

Im sorry but my HPUX knowledge is only basic.

Chad

6 REPLIES 6
DCE
Honored Contributor

Re: Cron Job Executing Script but Command not Working


try using the fully qualified path to omnimm.
Cron is limited in its shell functions..........
Steven E. Protter
Exalted Contributor

Re: Cron Job Executing Script but Command not Working

Shalom,

cron has no environment.

That means you need to set the PATH and anything else you need in the script.

Quick and dirty:

env > /tmp/env

Put the critical parts of that in the script your cronjob calls.

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
James R. Ferguson
Acclaimed Contributor

Re: Cron Job Executing Script but Command not Working

Hi Chad:

The answers already given regarding the use of absolute paths the definition of any environmental variables you need should rectify your problem. Please read the 'crontab(1)' manpages for more information there.

In addition, the use of the path '/bin' in HP-UX is deprecated. '/bin' is a symbolic (and transition) link to '/usr/bin'. You should use '/usr/bin/sh' for your POSIX shell.

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Cron Job Executing Script but Command not Working

Add this line very near the top of your script:

export PATH=${PATH}:/opt/omni/bin:/opt/omni/lbin

Cron's environment (including PATH) is intentionally very sparse.
If it ain't broke, I can fix that.
Chad Brindley
Regular Advisor

Re: Cron Job Executing Script but Command not Working

Hi Guys,

This works fine now, I put in the full path in the script and this works fine now.

Thanks again. I will assign points now, all tiops helpful though even though I chose the path of just adding /opt/omni/bin in front of my commands.

I didnt know this was a problem with cron jobs.

Thanks,

Chad
Chad Brindley
Regular Advisor

Re: Cron Job Executing Script but Command not Working

thanks all, points assigned accordingly. 10 for the exact answer but 8 and 9's for other s which would have worked but I didnt put into practice.

Chadders