On 11/22/2012 12:25 PM, Meike Stone wrote:
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:
- 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
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.