Operating System - HP-UX
1748252 Members
3903 Online
108760 Solutions
New Discussion юеВ

Re: Yet another scripting problem...

 
SOLVED
Go to solution
Don Spare
Regular Advisor

Yet another scripting problem...

I have written a script that I use to collect space statistics from both of my servers and all Oracle DBs on those servers. When I login as user 'oracle' and invoke it from the command line it works perfectly. But when I invoke it via cron all I get is an error that says: 'sh: Mail: Execute permission denied.'. I have no idea where this is coming from as I am not issuing any statements like that and mailx is called from inside another script that is the last line of this one. I've looked at environment setup and can see no difference from many other scripts that are similarly designed. Maybe I'm just too close to the problem. Can anyone help?
9 REPLIES 9
Hai Nguyen_1
Honored Contributor

Re: Yet another scripting problem...

Look at the permissions (mode bits, owership) of the called script which I believe that it was not set appropriately for the cron user.

Hai
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Yet another scripting problem...

See if the 6th field in your crontab is a '*'.
If it ain't broke, I can fix that.
Don Spare
Regular Advisor

Re: Yet another scripting problem...

That's not it. It is set rwxr-xr-x. And it doesn't even get to the last script. The error message I listed in my original request is the only output.
Don Spare
Regular Advisor

Re: Yet another scripting problem...

The crontab entry is as follows:

18 16 * * * * /dba/dba/maint/collect_space_usage_data.sh > /dba/dba/log/dwdev001/collect_space_usage_data.log 2>&1

(I've been playing with the times to make it run)
James R. Ferguson
Acclaimed Contributor

Re: Yet another scripting problem...

Hi:

'cron' provides a limited environment. Usually, at the least, you need to either specify absolute paths and/or set the PATH variable to that which your cron script needs. Remember too, that other environmental variables that you normally set when you login (using your profile) are not set in the unembellished cron environment.

You might place 'set -x' and 'set -u' in your script when you run it from cron to trace and trap unset variables.

Regards!

...JRF...
Don Spare
Regular Advisor

Re: Yet another scripting problem...

I have tried 'set -x' and echoing specific environment variables but none ever appear in the log. Only the error in my original message.
S.K. Chan
Honored Contributor

Re: Yet another scripting problem...

Clay is correct .. your 6th field in your crontab file entry is an "*". The format should be .. (1st->6th)

minute hour monthday month weekday command

and your cron entries ..

18 16 * * * *

has an additional "*". That is why you're getting this weird "sh:Mail.." error because root is trying to execute "Mail" command from root (/).


S.K. Chan
Honored Contributor

Re: Yet another scripting problem...

.. because the directory "Mail" is the first that appears (in order) in /.
Don Spare
Regular Advisor

Re: Yet another scripting problem...

The 6th field '*' was the problem. All is well and points have been assigned.

Thank you all very much.