Re: Why following ksh script not works in crontab?
Posted in 1998
We had similar problems. When running from crontab, the UNIX system
bypasses the standard execution of /etc/profile and ~/.profile. All the
PATH and informix variables necessary to run the job successfully are
therefore not set from the crontab. You probably have them setup in your
~/.profile for your session. Set these variables explicitly in your shell
script. If you have many such cron jobs, consider writing a common shell
script that exports all relevant environment variables and then calls other
subshells based on a parameter passed to it.
Hope this helps.
>The following ksh script works well in command line.
>But not work in crontab, why?
>
>-----------------------------------------------------------------------
>#!/bin/ksh
>
># Informix back up logical log and will create a file logical.log
>
>ontape -a << EOF>^M
>y^M
>EOF
>
># where ^M is return input in vi by type ctrl-V and Enter
>sleep 3
>
>hour=`date +%H`
>
>if [[ $hour -ge 9 && $hour -lt 12 ]]
>then cp logical.log logical_tape1.log
>else cp logical.log logical_tape2.log
>fi
>cat /dev/null > logical.log
>-------------------------------------------------------------------
>The above script runs perfectly if on command line. But when I schedual
>in the crontab, I always got 0 (zero) size of logical_tape1/2.log. It
>seems