LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-25-2009, 06:37 PM   #1
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Rep: Reputation: 15
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,
 
Old 04-25-2009, 06:55 PM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
Does your system have an /etc/environment file? Have you tried setting it in there?
 
Old 04-26-2009, 12:00 AM   #3
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Original Poster
Rep: Reputation: 15
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";
 
Old 04-26-2009, 12:00 AM   #4
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Original Poster
Rep: Reputation: 15
I did reboot after. To be sure.
 
Old 04-28-2009, 09:10 PM   #5
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Original Poster
Rep: Reputation: 15
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
 
Old 04-29-2009, 10:33 AM   #6
suhas!
Member
 
Registered: Mar 2007
Posts: 100

Rep: Reputation: 17
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.
 
Old 04-29-2009, 11:29 AM   #7
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,090

Rep: Reputation: 41
/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.
 
  


Reply

Tags
env, environment variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
global environment variables in shell script a.toraby Programming 2 11-11-2007 03:25 AM
set environment variables johnvdster Linux - Newbie 2 05-30-2006 05:15 AM
how do i set environment variables? guitarfella Slackware 2 12-04-2004 11:05 PM
How to set environment variables anjaan Linux - General 3 06-10-2004 02:04 PM
Help with the currently set environment variables!! apoc013 Linux - Newbie 6 01-21-2004 01:28 AM


All times are GMT -5. The time now is 04:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration