[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Environment in cronjobs: Fragen



* Gregor Schneider <rc46fi@googlemail.com> wrote:
> Tach auch,
> 
> folgendes Phaenomen:
> 
> Ich habe in meiner /etc/profile eine Umgebungsvariable gesetzt:
> 
> export CATALINA_HOME="/home/tomcat/www"
> 
> Wenn ich nun einen job via cron starte, existiert diese Variable
> nicht, ebenso wie viele andere Variablen, die normalerweise via
> etx/profile angezogen werden.
> 
> Der cronjob laeuft als root, als shell wird die bash verwendet.
> 
> Nun meine Frage:
> 
> Welche Umgebungsvariablen werden denn nun angezogen bzw. wo werden
> diese gesetzt? /etc/bash.rc und /etc/profile sind's definitiv
> nicht....

Die werden von cron nicht gesourced.
Welche cron gesetzt hat verrät dir man5 crontab:

,----
| Several  environment  variables  are  set  up  automatically  by
| the  cron(8)  daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME are
| set from the /etc/passwd line of the crontab's owner. PATH is set to
| "/usr/bin:/bin".  HOME, SHELL, and PATH may be overridden by settings in
| the  crontab;  LOGNAME is the user that the job is running from, and may
| not be changed.
| 
| (Another note: the LOGNAME variable is sometimes called USER on
| BSD systems...  on these systems, USER will be set also.)
| 
| In  addition  to  LOGNAME,  HOME,  and SHELL, cron(8) will look
| at MAILTO if it has any reason to send mail as a result of running
| commands in ``this'' crontab.  If MAILTO is defined (and non-empty),
| mail is sent to the user so named.  If MAILTO is defined but empty
| (MAILTO=""), no mail will  be  sent.  Otherwise mail is sent to the
| owner of the crontab.
`----

Wenn du Variablen aus /etc/profile setzen willst solltest du die im
aufgerufefnen Skript sourcen oder die Variablen dort setzen.

Gruß
Jens



Reply to: