0

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?

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.

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 deferent 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 callsystemd disableit remove the link from/etc/systemd/system/X/ But when you callchkconfiginsysvinitit remove the link from/etc/rc*.d`

  • But just disabling using systemctl works for me. I do have the script inside /etc/init.d/ – nithinj Dec 29 '16 at 9: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.