LinuxQuestions.org
Review your favorite Linux distribution.
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 05-25-2003, 09:39 PM   #1
yenonn
Member
 
Registered: Feb 2003
Location: Malaysia
Distribution: Redhat 8.0, 9, Slackware 9.1
Posts: 511

Rep: Reputation: 30
write a script to start a service..how??


i have done a squid installation and it was working quite ok for the time being.
now, i want to create a starting script and put it into directory /etc/rc.d/init.d, such that it will auto-start when the machine is booting.
so, the question is that any idea in creating this kind of script. where should i refer to? any example of script to let me customize it in order to suit my need? i never have experiences before this.

thanks!!!!

Last edited by yenonn; 05-25-2003 at 09:40 PM.
 
Old 05-25-2003, 09:52 PM   #2
Azmeen
Senior Member
 
Registered: May 2003
Location: Malaysia
Distribution: Slackware, LFS, CentOS
Posts: 1,307

Rep: Reputation: 46
create a text file and write this in it:

Code:
#!/bin/bash

/path/to/your/app --with-whatever --flags
That's be basic structure... you can use different shells at the shebang (the #!/bin/bash part in the example above).
 
Old 05-25-2003, 09:53 PM   #3
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
create a text file of what you would have
to type to start squid and save it in init.d as
a name you would remember. like squidder.
use chmod +x filename to make the file
executable.
in the runlevel that you use. maybe 3,
make a softlink from inside /etc/rc.d/rc.d
to the file squidder, called S99squidder
like
ln -s /etc/rc.d/init.d/squidder /etc/rc.d/rc.3/S99squidder
then it will start last in runlevel 3
 
Old 05-25-2003, 10:12 PM   #4
yenonn
Member
 
Registered: Feb 2003
Location: Malaysia
Distribution: Redhat 8.0, 9, Slackware 9.1
Posts: 511

Original Poster
Rep: Reputation: 30
what is the purpose of having a starting point at runlevel 3??
then, what if i want to stop the service when the system is shutting down?
will this my squid service be listed in "Service" screen list?
and how to make stop, restart function for that service?
thanks!
 
Old 05-25-2003, 10:20 PM   #5
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
i just guessed that your default runlevel is 3.
to make a start stop and restart service is more
complicated.
take one of the other scripts in /etc/init.d, copy it
and rename it, and edit it to suit your needs.
to have a service specifcally killed in a runlevel,
like shutdown which is 6, you make a link to a script
that kills squid, or you make your script more complex,
so that it checks how it is called.
start the kill script name with K.
 
Old 05-25-2003, 10:37 PM   #6
yenonn
Member
 
Registered: Feb 2003
Location: Malaysia
Distribution: Redhat 8.0, 9, Slackware 9.1
Posts: 511

Original Poster
Rep: Reputation: 30
how to determine my runlevel is 3? any command prompt that will comfirm my runlevel? confusing... u mean my script will content start, restart and stop command prompts...
and then, i have to make a link to rc.3 for start and restart purposes, subsequently, i have to make another link to rc.6 for stop purpose, with prefix "k" for that link's name?
i have took a glance over the rest of the scripts in /etc/rc.d/init.d. they are all look complicated... i have no idea in how to edit them...can u give an example of script that will showing a skeleton on how to customize it? thanks again!!!!!
 
Old 05-26-2003, 06:14 AM   #7
Azmeen
Senior Member
 
Registered: May 2003
Location: Malaysia
Distribution: Slackware, LFS, CentOS
Posts: 1,307

Rep: Reputation: 46
Runlevel 3 is the default runlevel during multi-user bootup. ie. if you bootup "normally", you'll be at runlevel 3.

To edit your rc.3 script, just open it up and insert this line:

/path/to/squid --arguments

where /path/to/squid is the full path to this squid application, and --arguments is any additional arguments you need to append to it (not necessary depending on how you normally run squid).
 
  


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
when i try to start samba pdc's smb service nmbd failed to start . sandeepchau123 Linux - Newbie 2 10-20-2007 02:59 PM
service does not start Aljaber Fedora 11 12-01-2005 08:07 PM
where a service should place a folder so every user can have read/write access. shahidawan Linux - Security 3 05-07-2005 02:25 PM
service could not start LinuxRam Linux - Newbie 4 08-26-2004 07:03 AM
Service start-up n.antonio Linux - Software 2 05-02-2003 10:57 PM


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