Making a script start with service?
I have a script which I want to start as:
Code:
service service-name start |
Hi,
No, it is not. Normally there is a file called skeleton in the /etc/init.d directory. You can use that as an example (or base) to create your own. Kind regards, Eric |
Dude,
I am using RHEL and it doesnt have that file(ASAIK) |
Hi,
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). Hope this helps. |
Hi,
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 ? Regards, rhadmn |
Quote:
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. Kind regards, Eric |
Guys,
I just have script which I want to start at boot time. So what I understand is : Code:
RHEL All if I want to start I will do: service myscript start |
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 Kind regards, Eric |
|
Eric,
chkconfig --add myscript is something which will make this script work as service. Thanks Druuna,. |
But when I did:
Code:
[root@rs init.d]# chkconfig --add myscript Surprisingly, Code:
#service myscript start |
Also,
I am unable to add up this service at boot time: #chkconfig myscript on service myscript does not support chkconfig |
Hi again,
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). The above is (an obvious?) example.... |
|
All times are GMT -5. The time now is 03:27 PM. |