On Mon, Jul 5, 2010 at 5:09 PM,  <[email protected]> wrote:
>>> Why does export not work ?
>>
>> Because you can't modify the parent process's environment variables.
>> When you run /usr/local/bin/cron_delay.sh, you are creating a new
>> process which executes /bin/sh (with the pathname of the script as its
>> first argument).  That new process can modify it's own environment
>> variables and pass them on to processes it creates, but it can't modify
>> the environment of its parent process.  This is a standard unix feature,
>> not a bug.
>>
>> It's possible to run the script within the current shell process
>> (instead of spawning a new process) using the "source" or "." built-in
>> shell command:
>>
>>  source /usr/local/bin/cron_delay.sh
>>
>> Since it's the current shell process that's running the commands in the
>> script, any changes to environment variables will be in the current
>> shell process, and will be passed on to any other processes created by
>> the current shell process.
>
>  Ian, thanks for taking the time to explain so thoroughly my stupid mistake.
>
> However, it is not working using source. I reduced my cron job to simply
> sourcing that script it fails to get called. Seeing no output form crond
> generally indicates an error in crontab.
>
> I tried su to the relevent account and ran crontab -l.
> $ crontab -l
> crontab: must be suid to work properly
>
> I have noted the warning that suggests busybox may need to be suid but
> hesitate since having just about any and all shell commands running suid
> makes me a bit twitchy. Until now this has never produced an issue in what I
> use this system for.

busybox drops suid privileves for applets which do not need them.
Only those with BB_SUID_REQUIRE in applets.h will retain the privileges.

> There are certainly other ways to get around what I need to do what I need
> but I don't like walking away from a problem just because I don't understand
> what is happening.
>
> This seems like an awful lot of effort and problems just to set an env var !
>
> 01,16,31,46,25  * * * * source /usr/local/bin/cron_delay.sh

No, this is wrong. "source" is a shell builtin, not a cron command.

I don't understand what do you want to do. You want to set
DELAY env var to 16 - *in which process*? In cron?
That's not possible to do from a cron job.

Cron job is a child of cron.

A process can only change its own environment, and control
what environment is passed to a newly created child.
It can't change environment of another already
running process (even if that process is its child).

Can you describe a "bigger" problem you are trying to solve,
since it looks like you are doing it all wrong.

-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to