Hello, in /etc/cron.d/test I've this: 50 15 * * * root ( date ; echo "---" ; env ; echo "---" ; set )>>/tmp/test.txtand I thought I would be shown environment variables which are defined in e.g. /etc/profiles.d/proxy.sh or /etc/profiles.d/proxy.csh but this isn't like this ... where do I have to define e.g. export http_proxy="http://proxy.local:3128/" in order to have it in cron jobs? Thanks, Walter
Liam O'Toole
2016-Dec-01 16:23 UTC
[CentOS] CentOS 6: environment variables and cronjobs ...
On 2016-12-01, Walter H. <walter.h at mathemainzel.info> wrote:> Hello, > > in > > /etc/cron.d/test > > I've this: > > 50 15 * * * root ( date ; echo "---" ; env ; echo "---" ; set ) >>>/tmp/test.txt > > and I thought I would be shown environment variables which are defined > in > > e.g. /etc/profiles.d/proxy.sh or /etc/profiles.d/proxy.csh > > but this isn't like this ...That is the expected behaviour.> > where do I have to define e.g. > export http_proxy="http://proxy.local:3128/" > in order to have it in cron jobs? > > Thanks, > WalterYou can set the variable in the cron job itself. See, for example, /etc/cron.d/0hourly, where several variables are set. -- Liam
Philippe BOURDEU d'AGUERRE
2016-Dec-02 07:53 UTC
[CentOS] CentOS 6: environment variables and cronjobs ...
Le 01/12/2016 ? 17:23, Liam O'Toole a ?crit :> On 2016-12-01, Walter H. > <walter.h at mathemainzel.info> wrote: >> Hello, >> >> in >> >> /etc/cron.d/test >> >> I've this: >> >> 50 15 * * * root ( date ; echo "---" ; env ; echo "---" ; set ) >>>> /tmp/test.txt >> >> and I thought I would be shown environment variables which are defined >> in >> >> e.g. /etc/profiles.d/proxy.sh or /etc/profiles.d/proxy.csh >> >> but this isn't like this ... > > That is the expected behaviour. > >> >> where do I have to define e.g. >> export http_proxy="http://proxy.local:3128/" >> in order to have it in cron jobs? >> >> Thanks, >> Walter > > You can set the variable in the cron job itself. See, for example, > /etc/cron.d/0hourly, where several variables are set. >You can also set environment variables in /etc/environment. They will be read by pam module pam_env. -- Philippe BOURDEU d'AGUERRE AIME - Campus de l'INSA http://aime-toulouse.fr/ 135 av. de Rangueil T?l +33 561 559 885 31077 TOULOUSE Cedex 4 - FRANCE Fax +33 561 559 870