[opensuse] how to set global environment variables in crontabs
Hello list, I've a question related to cron on SuSE. I like to set global environment variables for all cron jobs. I see, that per default the cron runs a /bin/sh (link to /bin/bash). But in this mode of bash, the profile file will not included. So my questions are: 1) Is there a possibility to set global environment variables with using /bin/sh? 2) Or if not, how do I configure the /bin/bash as default for all crontabs? I know, that I can set environment variables in the crontabs (cron.d, cron.daily, ...) itself, but that is not the requested solution. I tried to set the SHELL=/bin/bash in the /etc/crontab, but that is not working! Thanks for help Meike -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* Meike Stone <meike.stone@googlemail.com> [11-22-12 12:26]:
I've a question related to cron on SuSE.
I like to set global environment variables for all cron jobs. I see, that per default the cron runs a /bin/sh (link to /bin/bash). But in this mode of bash, the profile file will not included.
So my questions are:
1) Is there a possibility to set global environment variables with using /bin/sh? 2) Or if not, how do I configure the /bin/bash as default for all crontabs?
I know, that I can set environment variables in the crontabs (cron.d, cron.daily, ...) itself, but that is not the requested solution. I tried to set the SHELL=/bin/bash in the /etc/crontab, but that is not working!
set SHELL='/bin/sh -e script' set the env you wish in the script and continue in that env. note: I have not a need for this and have not tried, but it *should* work.(tm!) -- (paka)Patrick Shanahan Plainfield, Indiana, USA HOG # US1244711 http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 http://en.opensuse.org openSUSE Community Member Registered Linux User #207535 @ http://linuxcounter.net -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 11/22/2012 12:25 PM, Meike Stone wrote:
Hello list,
I've a question related to cron on SuSE.
I like to set global environment variables for all cron jobs. I see, that per default the cron runs a /bin/sh (link to /bin/bash). But in this mode of bash, the profile file will not included.
So my questions are:
1) Is there a possibility to set global environment variables with using /bin/sh? 2) Or if not, how do I configure the /bin/bash as default for all crontabs?
I know, that I can set environment variables in the crontabs (cron.d, cron.daily, ...) itself, but that is not the requested solution. I tried to set the SHELL=/bin/bash in the /etc/crontab, but that is not working!
Thanks for help
Meike
Just plop them into the top of /etc/crontab. This isn't true for all versions of cron, especially older ones or ones on other unixes. But it is true for vixie-cron/cronie and suse in general for many years. You'll have to describe more exactly what you did that didn't work, because it works for me. For instance, one thing I have is "CRON=true" near the top of /etc/crontab, and that variable is present in the environment of cron jobs. I use it so that certain scripts can be run interactively, non-interactively but not from cron, like cgi or rsh, and non-interactively from cron, and I need them to behave differently if run from cron than other times. Been doing the same thing for years on many many servers. -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Brian K. White
-
Meike Stone
-
Patrick Shanahan