简单的把SysV init转变成SystemD启动

Github上看到的,对于大部分的init script可以这么用,但是其实还是不太准确

Let’s say you have a SysV Init Script named foo

Copy the file to /etc/init.d/foo

Enable the SysV service: chkconfig --add foo

Enable the SysV service: chkconfig foo on

Start the service: service foo start. After this, systemd-sysv-generator will generate this file /run/systemd/generator.late/foo.service, copy this file to /etc/systemd/system by running: cp /run/systemd/generator.late/foo.service /etc/systemd/system/foo.service

Edit /etc/systemd/system/foo.service by running systemctl edit foo.service, add in the following line to foo.servie (this makes the service installable)

[Install] WantedBy=multi-user.target 

Enable the service: systemd enable foo.service

(Optional) You can then remove the SysV script by running

 foo off && chkconfig --del foo

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.