On Fri, Nov 19, 2004 at 12:48:07PM +1100, Dimitry Peisakhov wrote:
>       Thanks for the advice Michael. I have a question though.
> Services from init.d start up under root, as far as i know. Root
> currently has no TZ set, but all other services log correctly. If i
> set TZ in the spamd init.d script, that would set TZ for root, wouldnt
> it? (TZ is user-specific, i htink). Do you think this will still
> work? Would it impact any other time-related things?  I still find it
> strange that spamd is the only service that is logging and ignoring
> the system time.

Dimitry,

Environment stuff can be very tricky sometimes.  The settting of an
environment variable sets that variable for that process, and it more
than likely will be inherited by any child processes that are spawned by
that process and any of thier subsequent processes.

In my situation, what I had done is that I set my TZ variable in my
shell, and then I would do something like 'sudo /etc/init.d/httpd
restart' and the sudo command the /etc/init.d/httpd script and the httpd
daemons all inherited my variable and the httpd daemon was logging in my
timezone.

This is why many people do things as root or another daemon user like
oracle by doing 'su - USER' or 'su - USER -c COMMAND'.  Where the '-'
denotes that it will read all of the user's environment variables as if
they had logged in.  I personally don't like sudo because I rarely
remember (or want to remember) root passwords, so I use sudo with my
password.  I also prefer my environment the way I set it up with things
like VISUAL, EDITOR, and PAGER and/or MANPAGER to things that I like,
and are often unapropriate for system accounts.

Another confusing thing with environment variables is that it is
impossible to inject an environment variable into an already running
process.  But it makes sense once you think about it.

Mike

-- 
/-----------------------------------------\
| Michael Barnes <[EMAIL PROTECTED]> |
| UNIX Systems Administrator              |
| College of William and Mary             |
| Phone: (757) 879-3930                   |
\-----------------------------------------/

Reply via email to