1

My application should run on systems which run on systemd and older platforms where systemd is not available. So I am registering my service into run level using both chkconfig and systemctl enable.

What should I do to disable my service from run level? Should I disable using both systemctl and chkconfig?

nithinj
  • 180

2 Answers2

0

For sysvinit systems chkconfig create a link to the script that run your service from /etc/rc.d/init.d and put it on /etc/rc*.d depending on the run level you specify for your service.

For systemd systems systemctl enable create a link and put it in different folder from the chkconfig in the sysvinit systems.

For example, for multi user level its put it in /etc/systemd/system/multi-user.target.wants/

For you situation if you have a running script in /etc/init.d So when you call systemd disable it remove the link from /etc/systemd/system/X/ But when you call chkconfig in sysvinit it remove the link from /etc/rc*.d

user
  • 781
  • But just disabling using systemctl works for me. I do have the script inside /etc/init.d/ – nithinj Dec 29 '16 at 09:52
  • 1
    `[nithinj@vbox ~]$ chkconfig --list $servicename

    Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration.`. I assume the chkconfig data got overridden while disabling using systemctl. Thanks.

    – nithinj Dec 29 '16 at 10:00
  • @NithinJ you are right, i removed the last line in my answer – Wissam Roujoulah Dec 29 '16 at 10:24
  • Your answer is very much detailed. It will be helpful to add a one line answer (brief) in the top. Thanks. – nithinj Dec 29 '16 at 14:23
0

The clean solution is to check which init system is in use and then only run the command which applies to the init system that's in use.