I created a app and the service file , You can start / stop / restart the service ... I want to start that service at the time of booting of Suse Enterprise linux , I tried adding that file in /etc/init.d/my-service but its not getting started on boot
Asked
Active
Viewed 4.2k times
1 Answers
11
You have to add this file into desired runlevel. For example:
sudo update-rc.d my-service default
Will add it into default runlevel in Debian-based distros. Also, be sure that the file has such structure:
#!/bin/bash
case "$1" in
start)
#do startup commands
;;
stop)
#do stop commands
;;
esac
However, in SUSE Linux there is /etc/init.d/skeleton that should be edited to create new scripts. This skeleton contains special comments (they are comments for the shell, but used by YaST) to describe on which runlevels the start/stop must be.
Once done, the script will show in YaST → System → System Services (runlevel) and can be switched on/off from there (making the links, etc).
To enable a service you can also use chkconfig, as in:
chkconfig --set someservice on
or
chkconfig --set someservice off
and the appropriate links will be created/deleted. For finer control over levels, you can use
chkconfig --level 35 someservice on
Source: OpenSUSE update-rc.d equivalent.
Danatela
- 504
- 6
- 16
-
update-rc.d command not found , and its not available under /usr/sbin/ also ..... For more info am using SUSE Linux Enterprise 11 – asvignesh May 12 '14 at 11:33
-
1I updated the answer, hope this will help. – Danatela May 12 '14 at 11:57
-
Still no luck and one more issue ... when i start the service form /etc/init.d/my-service start its working fine but if i try service my-service start didn't start my app – asvignesh May 12 '14 at 12:11
-
1OK I will download SLES and test it... – Danatela May 12 '14 at 12:20
-
hey dont waste resource for this thing .... i u have any suggetions let me know – asvignesh May 12 '14 at 12:21
-
2You don't need to upvote each my comment ;) What does `chkconfig` tell to you? – Danatela May 12 '14 at 14:58
-
I am on OpenSUSE LEAP v15.3 and there is no such file `/etc/init.d/skeleton`. Has that mechanism been replaced with something else or does that description strictly hold for SLES only but not for OpenSUSE? – mmo Apr 29 '22 at 10:48