This should be simple, but it turns out to be a pain: How do I set an environment variable in CentOS (3.9) so that it is globally available for all users as well as for all cron jobs?
The variable in question is PERL5LIB
Here is what I have tried:
This did not do anything. rc.local is perhaps being called as in a child shell, so the setting gets lost when shell exits?
This works for user logins, but not for cron.
This does not take effect for cron jobs (for some reason).
In the root cronjob itself:
*/1 * * * * echo $PERL5LIB > /tmp/t.txt
This again does not have any effect (the test cron job creates an empty file).
I would like to know if there is ONE place to put this so that it takes effect everywhere (or possibly two places: one for user logins and one for cron jobs).
This works, but I do not want the redundancy of having export statements all over the place:
*/1 * * * * export PERL5LIB=/d1/lib/perl ; echo $PERL5LIB > /tmp/t2.txt
Adding this line to the start of every perl script also works, but again I am looking for a more global solution to this:
use lib qw(/d1/lib/perl);
Any solution to this?