Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-22-2010, 06:47 AM   #1
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/ run"

is there any issue with the syntax?

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

Rep: Reputation: 113Reputation: 113
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, 10:35 AM   #3
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:

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

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.


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

All times are GMT -5. The time now is 09:48 PM.

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