LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-22-2010, 07:47 AM   #1
sajhak
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
Question Adding an environment variable to inittab


Hi all,

im quite new to Unix stuff

Im in need to add a script to be executed, in to /etc/inittab

for that i need to get the path to my java installation.

I have set the JAVA_HOME env variable already, my question is whether we can use JAVA_HOME in inittab? i mean, are those env variables are crated by the time inittab starts?

if so, how can i add the entry

currently im having is like this
pse:5:respawn:su - <username> -c "$JAVA_HOME/other-path/pp.sh run"

is there any issue with the syntax?

Thanks in advance
shk
 
Old 07-22-2010, 10:29 AM   #2
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 111Reputation: 111
Hi sajhak,

Which distro you are using ?

If you want to run script at boot time the you can add enty in rc.local file instead of inittab.
 
Old 07-22-2010, 11:35 AM   #3
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Hi sajhak,

Please do not edit the inittab, unless you know exactly what you're doing. The inittab controls the run level which the OS boots into; and an errorneous inittab can result in you having to reinstall and/or rescue the OS.

If you want to persist your JAVA_HOME environment variable; every time you login; this is done in the following way:

1. Login as the user that you want the JAVA_HOME to be set for - remember every user has a set of environment variables.

2. Edit the /home/myuser/.bash_profile:

Code:
$ vim /home/myuser/.bash_profile
3. Add the following in:

Code:
export JAVA_HOME=/path/to/my/java/home/dir
4. Save and logout.

Thereafter; whenever you login as that particular user; your JAVA_HOME will be set.

In terms of having a script run every time you reboot; give me a bit more information on the script and the distro you're using and I can advise.
 
  


Reply


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
keep environment variable manelameur Ubuntu 13 02-06-2010 12:01 AM
!! environment variable !! sonu kumar Linux - Newbie 7 11-07-2009 03:59 AM
Environment Variable linux_linux Linux - Newbie 4 03-20-2008 11:16 PM
Environment variable vedanu Programming 1 05-17-2007 08:20 AM
Environment variable.. manomohan Programming 1 02-27-2007 12:27 AM


All times are GMT -5. The time now is 10:24 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration