LinuxQuestions.org
Register a domain and help support LQ
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 03-19-2009, 12:04 AM   #1
haseit
LQ Newbie
 
Registered: Jan 2009
Location: Colombo / Sri Lanka
Posts: 14

Rep: Reputation: 0
Run Shell script when boot Linux


Hello All,

I have a problem related to execute the shell script which will run a .jar pls help me on this matter.

1. In Red Hat Linux flavors where should i place the shell script?

2. In Debian Linux flavors where should i place the shell script?

3. How to make them execute? (access permissions)

Thank you,
Hasantha
 
Old 03-19-2009, 12:25 AM   #2
mk27
Member
 
Registered: Sep 2008
Distribution: fedora, gentoo, ubuntu
Posts: 148

Rep: Reputation: 23
You should read up on runlevel scripts. They are all owned by root, mode 755. For Fedora, they are in /etc/rc.d/init.d, for debian /etc/init.d.

But they need to be linked into a runlevel directory (/etc/rc?.d). You will have to do some googling and reading to figure out which one. Basically, you do this:
Code:
ln -s /etc/init.d/myscript /etc/rc5.d/S50myscript
The rc?.d number corresponds to the runlevels managed by init (0,1,2,3,4,5,6)
The softlink name must begin with "S" for start and a number 0-99, which is the priority. You will find these directories full of such things.

The scripts have a particular start|stop|restart structure, which it is up to you whether to follow that or not, they will work fine anyway (that is up to you too).

Last edited by mk27; 03-19-2009 at 12:26 AM.
 
Old 03-19-2009, 02:07 AM   #3
emailbuilder88
LQ Newbie
 
Registered: May 2005
Posts: 23

Rep: Reputation: 1
You can cheat too, by adding a call to your own script/application in:

/etc/rc.d/rc.local

But mk27's suggestion is the Right Way to do it.
 
Old 03-19-2009, 08:26 PM   #4
JaksoDebr
Member
 
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
You can also add your scripts as a cron job. In that case it is irrelevant where they are placed, but make sure to use full pathnames within the script and also in the cron job definition. The script should be set to executable with chmod.

Cron jobs do not have to belong to root, unless your script needs access to locations and tools owned by root.

Linux Archive

Last edited by JaksoDebr; 04-02-2009 at 06:14 AM.
 
  


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
how to automatic run a shell script at boot? ceantuco Linux - Newbie 36 10-09-2008 01:08 PM
How to run a shell script on boot up? AussieGit Linux - Newbie 4 11-02-2005 07:10 PM
Run shell script in RedHat after boot dmorse Linux - General 1 08-23-2005 02:54 PM
RH8 - how to automatically run a shell script at boot time nu-B Linux - Newbie 2 11-03-2003 03:47 PM
RH8 - how to automatically run iptables rules shell script at boot time nu-B Linux - General 1 10-29-2003 09:38 PM


All times are GMT -5. The time now is 10:29 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