LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 09-20-2004, 07:32 AM   #1
robbiemorgan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Rep: Reputation: 0
Correct way to run daemon at startup


Hi,

I'm running thttpd to serve my static content. What's the best/correct way to have it run at startup? Should I add a line to rc.local? I'm running Suse 9.

Thanks,

Rob
 
Old 09-20-2004, 08:17 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
Adding it to rc.local is a perfectly valid (and simple) way to start it, but note that this will always be started regardless of the runlevel.

The “better” way is to create a script in /etc/init.d that starts the daemon if called with the command-line option “start”, stops it with “stop”, restarts it with “restart”, or reloads it (signals it to re-read its configuration files, if any) with “reload”. You can then create a symbolic link to this script in each of the various runlevel directories, of this form:

/etc/rcX.d/SYYname

Where:
X is the runlevel (one symlink for each runlevel)
S means start the daemon on entering this runlevel (replace with K to stop the daemon instead)
YY is a number; daemons are started/stopped in the order when sorted by this number
name is the name of the script to start/stop the daemon

The only real advantage of the latter approach is that you can then use the YaST's runlevel editor to start and stop the daemon.
 
Old 09-20-2004, 08:25 AM   #3
robbiemorgan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks rjlee - very helpful.

Think I'll go for the "better" approach, like the idea of being able to start/stop/restart easily.

Really stupid question - but what's a runlevel?

Thanks,

Rob
 
Old 09-20-2004, 08:40 AM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
It's a configuration, a list of services running. You can have many runlevels in your system (plus special ones for reboot, for example), so different configurations you can switch between. You can see a list in /etc/inittab (comments at the beginning of the file).
 
Old 09-20-2004, 08:49 AM   #5
robbiemorgan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Ok, so I see there's a startup script for Apache in '/etc/init.d/rc3.d' called 'S02httpd', would 'rc3.d' be right right place to put a startup script for thttpd? What is the difference between the runlevels?

Thanks,

Rob
 
Old 09-20-2004, 08:59 AM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
The script in /etc/init.d/rc3.d is probably just a symlink to one in /etc/rc.d/init.d. Directories like rc3.d are places where runlevel configuration is kept. 3 means it's runlevel 3. If you use that runlevel and wish to run thttpd on it, copy/symlink your starting script. To see your current runlevel run 'runlevel' command.
What's the difference between runlevels? Browse /etc/init.d/rc2.d, rc3.d etc. You should see different sets of scripts. That's the difference. The services started at boot at a certain runlevel. I may add that you can completely reconfigure them to suit your needs.
 
Old 09-20-2004, 09:09 AM   #7
robbiemorgan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks Mara.

So, would this do as a template for the runtime script? It says it's for Solaris but I assume the syntax is the same:

http://www.tech-recipes.com/solaris_...n_tips148.html
 
Old 09-20-2004, 09:11 AM   #8
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 67
Yes, but replace /usr/iplanet/webserver/https-www.tech-recipes.com/start stop etc. with the actual commands to start/stop your daemon.
 
Old 09-20-2004, 09:19 AM   #9
robbiemorgan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Now you're just mocking me No worries, I can take it from here. Thanks again for your help guys.
 
  


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
Problems getting a startup script starting at the correct time BrianK Suse/Novell 3 11-13-2005 06:15 AM
Any way to startup daemon automatically? Niceman2005 Linux - Newbie 2 01-12-2005 10:27 PM
Startup Daemon on Boot EuroJovi Linux - Newbie 4 01-09-2004 11:39 AM
Getting daemon to run at startup HaPPYFaCe Slackware 1 07-10-2003 09:50 PM
Adding a new daemon to startup wayloud Linux - Newbie 2 01-18-2003 05:24 AM


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