LinuxQuestions.org
Help answer threads with 0 replies.
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 08-20-2010, 02:37 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Linking init script to specific rc0.d, rc1.d etc directories


Hi All,

I have written an init script which I have kept under /etc/init.d, I need to create links to the directories rc0.d, rc1.d, rc2.d, rc3.d etc..

So that I can use chkconfig command to control the starting and stopping of the script at specific runlevels.

Any good tutorials for this ? Please advice.

Thanks in advnace.
 
Old 08-20-2010, 03:36 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Simply, all you need is ln -s:
Code:
ln -s /etc/init.d/<your_script> /etc/rc3.d/S64<service_name>
ln -s /etc/init.d/<your_script> /etc/rc5.d/S64<service_name>
ln -s /etc/init.d/<your_script> /etc/rc0.d/K36<service_name>
ln -s /etc/init.d/<your_script> /etc/rc6.d/K36<service_name>
S stand for Start and K means Kill.

On the other way, if you put the description about runlevel, processname, ... at the begin of init script, something like this:
Code:
# chkconfig: - 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid
and execute:
Code:
chkconfig --add <service_name>
chkconfig <service_name> on
it will automatically create symlinks for you.

Last edited by quanta; 08-21-2010 at 12:50 PM.
 
Old 08-20-2010, 03:40 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Thanks a lot quanta.

I have a small doubt

Code:
# chkconfig: - 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

In the above code, Are 64 and 36 arbitrary numbers. Is their any constraint to choose these numbers ?

Thanks in advance.

Last edited by vinaytp; 08-20-2010 at 03:45 AM.
 
Old 08-20-2010, 03:55 AM   #4
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Looking at the line begining with # chkconfig: - means all runlevel, you can change to something like 35. 64 is priority to start your service, and 36 is priority to stop. There is no contraint to choose these numbers but I often choose around the priority of common services: sshd, mysqld, httpd, ntpd, ...

Last edited by quanta; 08-21-2010 at 11:43 PM.
 
Old 08-20-2010, 04:01 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by quanta View Post
Looking at the line begining with # chkconfig: - mean all runlevel, you can change to something like 35. 64 is priority to start your service, and 36 is priority to stop. There is no contraint to choose these numbers but I often choose around the priority of common services: sshd, mysqld, httpd, ntpd, ...
Thanks again for detailed explanation..
 
  


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
linking to /etc/init.d czezz Linux - Server 4 07-31-2009 04:59 AM
Linking Directories aquaboot Debian 5 06-07-2009 09:08 AM
linking directories david@aber Linux - Newbie 3 11-25-2004 08:45 AM
Linking Directories utahcon Linux - General 1 08-11-2004 07:54 PM
Symbolic linking directories leecming Linux - General 1 06-08-2004 12:11 PM


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