| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-25-2009, 06:37 PM
|
#1
|
|
LQ Newbie
Registered: Apr 2009
Posts: 28
Rep:
|
how to set global environment variables?
Hi,
I am setting PATH=$PATH:/demia on /etc/profile
it is supposed to set it globally but cronjobs are unaware of those newly set variables. Only root (without su) is aware of it.
i would like to set this once from a script at boot time and i want every user, every su command, every cronjob to access it without further ado.
Any ideas?
Thanks,
|
|
|
|
04-25-2009, 06:55 PM
|
#2
|
|
Member
Registered: Sep 2004
Location: solihull.w-mids.uk
Distribution: Debian 5.0, CentOs, Solaris 8-10
Posts: 576
Rep:
|
Does your system have an /etc/environment file? Have you tried setting it in there?
|
|
|
|
04-26-2009, 12:00 AM
|
#3
|
|
LQ Newbie
Registered: Apr 2009
Posts: 28
Original Poster
Rep:
|
I just set them there, but nothing happened.
$ env
doesnot show any variable that resides in the file you mentioned.
Thanks,
snippet from /etc/environment
-----------------------------
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/ami_tools/bin";
export JAVA_HOME="/usr";
export EC2_HOME="/home/ami_tools";
|
|
|
|
04-26-2009, 12:00 AM
|
#4
|
|
LQ Newbie
Registered: Apr 2009
Posts: 28
Original Poster
Rep:
|
I did reboot after. To be sure.
|
|
|
|
04-28-2009, 09:10 PM
|
#5
|
|
LQ Newbie
Registered: Apr 2009
Posts: 28
Original Poster
Rep:
|
I found out that environment file is not shell so for others, quick note:
format is below: it works this way.
PATH=/asdfasd
GO=/asdf
|
|
|
|
04-29-2009, 10:33 AM
|
#6
|
|
Member
Registered: Mar 2007
Posts: 100
Rep:
|
crontab has its own PATH settings. You have to edit the PATH setting there in /etc/crontab file
______________
$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
_______________
or if you are doing crontab -e, then you can manually add "PATH=<your paths>" at the top.
Regards.
|
|
|
|
04-29-2009, 11:29 AM
|
#7
|
|
Senior Member
Registered: Sep 2003
Posts: 1,089
Rep:
|
/etc/profile.local in Suse. I generally call my scripts in cron with, su -c which will load the appropriate localized user environment variables.
Last edited by trey85stang; 04-29-2009 at 11:30 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:43 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|