1748223 Members
4536 Online
108759 Solutions
New Discussion юеВ

Script issue!!

 
SOLVED
Go to solution
jeevarajkn
Frequent Advisor

Script issue!!

Hi All

Server--RX 3600

OS -HPUX 11.23

Iam facing issue while executing the script through cron.But If iam manually executing the script its working fine...

Script setails:--it will zip some trace files in source and will move these zip files to destination.

If iam executing this script through cron its giving error "unable to zip, GZIP not found"

but if iam manually do the zip in souce then iam try to run the script using cron its working fine.

Crontab entry.

30 18 * * * /pcard17/trace/movetrace

can anybody help me in this case.

Please find the attached script...

5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script issue!!

Hi:

> its giving error "unable to zip, GZIP not found"

Yes, I would expect that. Cron only provides a minimal environment. In the case of the PATH,, it consists only of:

PATH=/usr/bin:/usr/sbin:.

You need to use absolute paths for any commands not in the above or define you PATH list in your script. Any other environmental varaibles that you have defined in your login profile need to be defined too. The '.profile' sourced during normal logins is not handled for cron tasks.

See the 'crontab' manpages for more information.

Regards!

...JRF...
jeevarajkn
Frequent Advisor

Re: Script issue!!

Yes Jamous

I have given the absolute path for gzip command its belogs to /usr/contrib/bin but same result.

can u plesae tell me exactly what change wants to make in that script.

thnaks in advance..
Johnson Punniyalingam
Honored Contributor

Re: Script issue!!

Hi Jeeva,

Can you try calling script by creating file,

Example:-

vi movetrace.sh
/usr/contrib/bin/gzip
mv /myhome/
/usr/contrib/bin/gunzip /myhome/

# Crontab -e
30 18 * * * /pcard17/trace/movetrace.sh

Thanks,
Johnson



Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: Script issue!!

>I have given the absolute path for gzip command

That should fix it.
If you have other errors, add "set -x" to the script so you can see where it fails.

You may also change your find -exec to use "+" for performance:
-exec ls -ltr {} +

As a stylistic point, instead of passing info to your move function through the variable "a", you may want to pass it explicitly as a parm:
move $a
And inside of move, use "file=$1" and then use $file throughout.

Also, why use test instead of the shell builtin "[ ... ]"?
(And indentation helps. ;-)
jeevarajkn
Frequent Advisor

Re: Script issue!!

Thanks. Am closing the case.