Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you want to automatically start a service at (re)boot time you need to:
1) put the script in the init.d (depends on the distro if this is /etc/init.d or the correct /etc/rc.d/init.d),
2) make links to the appropriate runlevels.
Point number 2 can be done by hand, but most distro's have a utility for it. Red hat uses chkconfig. This would add the service to runlevels 3, 4 and 5: /sbin/chkconfig ––level 345 [name] on.
You mention more then one distro in your profile, so you need to check what the command is for your distro.
If you want to do it by hand:
cd /etc/rc.d/init.d
ln -s <service> ../rc3.d/SXXservice
ln -s <service> ../rc3.d/Kyyservice
The S reflect a start, the K reflects a kill. The xx and yy are numbers and point to the time the service needs starting (S10service will be started before S20service).
Kindly requesting you to please update your exact requirement.Do u want the services to be started via the script ? If YES ..is there any specific days/time etc ?
I am using RHEL and it doesnt have that file(ASAIK)
You didn't mention that now did you?
Then look at one of the scripts in there, copy it and edit to your likings. Then if you want to start it automatically at boot, follow the steps indicated by Druuna.
Not very familiar with RedHat but in my opinion if you're giving a parameter 'start' to a command then that command must now what it has to do. If you just copy your script to the init.d directory and it's not written to accept arguments like start|stop and so on, then you'll not be able to execute:
Code:
service yourscript start
That's why I pointed you at the skeleton file. If that doesn't exist on your server then copy an existing one in that directory and change it to call your script.
[root@rs init.d]# chkconfig --add myscript
service myscript does not support chkconfig
[root@rs init.d]#
I only wrote a script myscript:
#cat myscript
#!/bin/sh
service nfs stop
Am I doing anything wrong?
Surprisingly,
Code:
#service myscript start
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS services: [ OK ]
When I ran the above command without chkconfig --add option.
It worked !!!
Last edited by your_shadow03; 12-05-2009 at 04:42 AM.
I think you need to add something like this to your script:
#chkconfig: 2345 80 05
#description: Oracle 8 Server
The second line is the discription, the first tells chkconfig which runlevels the script needs to start/stop the 80 and 05 in the example are the start (80 -> S80oracle) point and the stop point (K05oracle).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.