LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-01-2010, 09:40 AM   #1
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Rep: Reputation: 51
How do I start up a shell script when the system starts?


This is on Fedora 11.


Thanks.
 
Old 03-01-2010, 09:47 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Edit /etc/rc.d/rc.local
 
Old 03-01-2010, 09:51 AM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,310

Rep: Reputation: 139Reputation: 139
The easiest way is to stick the script in /etc/rc.d/rc.local. Other that that, you put your script in /etc/rc.d/init.d and make the appropriate links to the runlevels you want the script to run in by liniking the script to the appropriate /etc/rc.d/rc*.d directory.
 
Old 03-01-2010, 09:57 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Original Poster
Rep: Reputation: 51
Er - what do I do if I want it run in ALL runlevels?


Which runlevel does Fedora normally boot to anwyay?
 
Old 03-01-2010, 10:03 AM   #5
cdbunch
LQ Newbie
 
Registered: Mar 2008
Posts: 13

Rep: Reputation: 0
There are a number of places where that can be done. The right place to do it depends a lot on what the script is supposed to accomplish. If you could clarify that it would make it easier to give a good answer.

If what you want to do is something along the lines of starting up a service process then putting a properly structured script in /etc/init.d and setting up the appropriate links to it with chkconfig could be an option. Then you could specify which run levels you want the script to be executed for.

Another option is running it from /etc/rc.d/rc.local which is intended for system customization and runs after the /etc/init.d scripts. This may be important if your script is going to depend on something that the system startup scripts have launched.

Also, I assume you want it to start during boot up. If you wanted it to start on login that would be done differently.

Cameron Bunch
 
Old 03-01-2010, 10:27 AM   #6
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,310

Rep: Reputation: 139Reputation: 139
Here's a nice overview of the RH/Fedora init process and configuration:

http://www.chinalinuxpub.com/doc/www.../runlevels.htm

For a GUI desktop, fedora normally boots to runlevel 5. For a text login like you typically have on a server, fedora boots to runlevel 3. As noted above, we need more details about what exactly you want to accomplish. Scripts launched from rc.local or init.d run with root privileges which may not be what you want.
 
Old 03-01-2010, 11:32 AM   #7
resetreset
Senior Member
 
Registered: Mar 2008
Location: India
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,320

Original Poster
Rep: Reputation: 51
I wanted to know this for just a hypothetical case - my friend needs to maybe disable his USB port sometimes while booting.

And yeah, I know about .bash_profile Thanks for offering to help anyway.
 
  


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
Issues with Fedora, cannot boot. File system check fails, no shell starts. Mamsaac Linux - General 8 10-20-2009 01:27 AM
make sure start up script starts after xorg has knobby67 Debian 1 11-09-2008 05:23 PM
mysql start script reports an error although server starts correcly gerryino Debian 0 10-08-2008 11:30 AM
KDE won't start; system starts in tty1 Jags_FL Slackware 8 02-22-2008 08:41 PM
How to ensure that a script start before kde starts? adityavpratap Slackware 3 06-03-2007 03:42 AM


All times are GMT -5. The time now is 07:08 AM.

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