On 07/05/10 17:47, Denys Vlasenko wrote:
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.


Huh? The following line has been working for two years.

00,15,30,45 * * * * cd /www/apache/cgi-bin/ && gnuplot test.gnu

cd is BB as is the shell, what's the difference?



man cron gives the following example:

       5 4 * * sun     echo "run at 5 after 4 every sunday"

What do you mean by "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.


Sorry if the the crontab was confusing. I made it as short as possible to test it. This is not the end objective !

The point is crond is not firing on this line. Usually I see something like the following on console each time crond triggers a crontab entry.

crond[324]: crond: USER .............

Nothing is happening at the time intervals I set in the line I posted. I have found this usually happens if there is an error in the crontab. Seeing nothing was happening I cut it down to the bare minimum to test using source.

The functionality I need to create is to pass a delay value to gnuplot. I have this working for a cgi responder that sets the env and calls gnuplot, but I can't get the crond end to work. The gnuplot script tests the value of DELAY to determine certain actions.

in essence I want something like this:

00,15,30,45 * * * * source /usr/local/bin/cron_plot_delay.sh && gnuplot test.gnu

I think using source should do it , my problem seems to be the crontab is not getting run.

At this stage I don't have an env var problem I have a crond problem.

Thanks again.

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

Reply via email to