Operating System - HP-UX
1839548 Members
2669 Online
110147 Solutions
New Discussion

Script not working properly via cron

 
SOLVED
Go to solution
Maarten van Maanen
Regular Advisor

Script not working properly via cron

I have a script in cron is which the arraydsp -a command is used to give me an overview of the AutoRAID settings. All output is written to file and later printed. Script is working fine except for the fact that arraydsp -a will not give any output. Running the script manually however, it works fine.
Anyone any ideas ??
7 REPLIES 7
John Palmer
Honored Contributor
Solution

Re: Script not working properly via cron

It's probably because the PATH variable is not set to the same value by a cron job.

Either set PATH in your script or change your script to call /opt/hparray/bin/arraydsp instead if just arraydsp.
James R. Ferguson
Acclaimed Contributor

Re: Script not working properly via cron

Maarten:

You may have some environmental variables which have been exported when you profile is sourced at login that are not present when cron initiates your script. You could always source your profile ahead of your script in the cron entry and see if that solves/helps your problem.

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Script not working properly via cron

Maarten:

You may have some environmental variables which have been exported when you profile is sourced at login that are not present when cron initiates your script. You could always source your profile ahead of your script in the cron entry and see if that solves/helps your problem.

...JRF...
Antoanetta Naghiu
Esteemed Contributor

Re: Script not working properly via cron

I agree with John's idea. Give the absolute path. Check as well root's mail and syslog. Cron reports the error.
Albert Smith_1
Regular Advisor

Re: Script not working properly via cron

I would check root's mail file and see if cron is reporting the error there. Normally if there is an error that is not handled properly by the script : I.E. not redirected via 2>/dev/null the error will get dumped. If the error's are not being redirected then check the mail and you will see the problem. If not and you are redirecting. Remove the redirect and run the script again via cron and look at the error output. You will be able to proceed from there.
Rick Garland
Honored Contributor

Re: Script not working properly via cron

Indicate the full path to the command via the script you are executing through cron. The $PATH is not carried through when executing through cron. When inputing into cron, use the full path to the command as well.
Maarten van Maanen
Regular Advisor

Re: Script not working properly via cron

You are all right on this. Arraydsp does not reside in the usual /usr/bin or /usr/sbin so I gave the wrong path !
Should have thought of this myself of course.