[PLUG] Shell questions
D. Cooper Stevenson
cooper at linux-enterprise.net
Wed Jun 5 15:19:26 UTC 2002
On Wed, 2002-06-05 at 07:43, Michael H.Collins wrote:
<snip>
> ##########
> I have a couple .sh scripts that if I run out my shell (bash) runs fine,
> but if I put on the cron (crontab) it loses its env vars (like
> $SOMETHING), even calling su root -c myscript.sh on the crontab
Guess what! Your environment variables aren't getting exported from the
shell process that is running your cron task!
For example, let's say you have `foo=/temp_file' in your script and you
call it from cron like so (the times are for illustration only, I don't
have cron's man page in front of me)
0 0 0 5 6 /usr/local/bin/my_cron_script
Under this scenario, cron reads your cron script and *forks another
process to run it!*
Change the cron line to this (note the period):
0 0 0 5 6 . /usr/local/bin/my_cron_script
This exports the variables it read in the parent process to the child
processes that will actually run your command.
-Cooper
More information about the PLUG
mailing list