LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 08-22-2008, 10:22 AM   #1
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Rep: Reputation: 0
Angry Help [URGENT]


Hi Experts,


I am trying to write a shell script to load JAVA_HOME at startup. Can someone tell me how to go about it? and which directory i should place my script in to run at startup.

Please help!
 
Old 08-22-2008, 10:28 AM   #2
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
Routines (scripts) that will run at startup can be found in /etc/rc.d/rc.local or do the full Sys V style init stuff.

Dave
 
Old 08-22-2008, 10:31 AM   #3
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
JAVA_HOME is more like an environment variable for users, placing this in an rc.local or startup script isn't going to do anything for you. You should place this in the global /etc/profile or in each users individual .bash_profile or .bashrc.

And next time use a more descriptive thread title, "Help [URGENT]" doesn't describe your problem and members here help people like you in their own free time, you're issue is no more important than the next members so don't tag threads as urgent.
 
Old 08-22-2008, 10:33 AM   #4
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks david!

Can you post me a sample script for loading JAVA_HOME at runtime please - help if you've got one.
 
Old 08-22-2008, 10:36 AM   #5
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by losintikfos View Post
Thanks david!

Can you post me a sample script for loading JAVA_HOME at runtime please - help if you've got one.
See my post, adding JAVA_HOME to a startup script isn't going to help you.

Simply do this in /etc/profile or your users /home/user/.bash_profile:

JAVA_HOME=/path/to/java
 
Old 08-22-2008, 10:39 AM   #6
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
trickykid i absolutly take your advice - won't happen again. also i think what you saying is right! .bashrc will do the trick for the enviromental variable setting - very please with that.


Quick question! do you have any sample script that will execute java class at startup?
!
for example java -classpath /root/Download/sforceAPi/sforceAPP/ Server.class
 
Old 08-22-2008, 10:41 AM   #7
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by losintikfos View Post
Quick question! do you have any sample script that will execute java class at startup?
!
for example java -classpath /root/Download/sforceAPi/sforceAPP/ Server.class
That you could probably place in the rc.local script usually found in /etc/init.d or /etc/rc.d, depending on what OS you are using and where the startup scripts are located.
 
Old 08-22-2008, 10:47 AM   #8
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
i am using RedHat tricky! do you think it would be init.d or rc.d?
 
Old 08-22-2008, 10:50 AM   #9
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
sorry tricky! i think i found the rc.local in rc.d so will place the java string to run the class in and restart my server to test it.

Cheers!
 
Old 08-22-2008, 11:08 AM   #10
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
it did the trick tricky!
 
Old 08-22-2008, 11:25 AM   #11
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally Posted by losintikfos View Post
it did the trick tricky!
Cool!I hate the 10 character limit

Last edited by trickykid; 08-22-2008 at 11:30 AM.
 
Old 08-22-2008, 12:19 PM   #12
losintikfos
LQ Newbie
 
Registered: Aug 2008
Posts: 13

Original Poster
Rep: Reputation: 0
Container to host startup script!

Hi Experts,


I have created a startup script call rc.loop.
I am currently running RedHat so have put the script in etc/rc.d/ area.

My question is will it run as part of the script at startup?


Thanks
 
Old 08-22-2008, 12:23 PM   #13
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
I do not think so. If you include it in rc.local, it will, though.

Dave
 
Old 08-22-2008, 12:50 PM   #14
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
You could add this file to the /etc/readahead.early.files

Just make sure it's executable. You could add it after the /etc/rc.d/rc.local in the file to get invoked after rc.local
 
Old 08-22-2008, 01:06 PM   #15
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Sorry, the readahead.early.files is just a sanity check which I like to add startup scripts to, etc. To have rc.loop start, you have to create a script to invoke it as well. You can add it to rc.local but it's probably better to have it's own so it's independent from rc.local

Like rc.local is called by S99local usually in each rcX.d directory in /etc/rc.d
 
  


Reply

Tags
bashprofile, environment, javahome


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
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 11:21 AM
how to mv the files...urgent...urgent manojkarthi Programming 2 07-02-2008 03:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 09:07 PM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 03:22 AM


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

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration