LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
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
LQ 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,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
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: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
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,987

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
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: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Original Poster
Rep: Reputation: 62
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:46 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
Open Source Consulting | Domain Registration