Re: Why following ksh script not works in crontab?
Posted in 1998
Ruiming Chen wrote:
> The following ksh script works well in command line.
> But not work in crontab, why?
>
>[...example omitted...]
>
> 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 to me the script does the "cp"
> command before the "ontape -a" processing finish. I even put a
> "sleep" between them. Why is that?
>
> Do I have to run the script in background in crontab? like
>
> 0 10,13 * * * mybackup_script &
>
> Currently I don't put in background "&"
>
> BTW, My OS is HP-UX 10.20, database is Informix Dynamic Server 7.3.
> For those who has OS Solaris 2.5/6.x, do you have this problem?
> To all, do you have solution for me? Thank you very much in advance!
Whenever something works on the command line and not in cron,
suspect the environment.
All cron-run jobs have an utterly minimal environment -- typically,
PATH, HOME, LOGNAME perhaps, and that's it. Occasionally, you get
one or two other random variables, such as HZ. Most probably, the
ontape is failing because the Informix environment is not set.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>