6月 232017
 

sysvinit 管理服务使用的是service命令,执行的是 /etc/init.d/{$script} 的逻辑;而systemd 使用的是systemctl来管理服务的。

我们如果在systemd系统上使用service命令(甚至直接执行 /etc/init.d/ 下的脚本)时,会提示自动重定向到systemctl来处理,其逻辑为:

service 为 initscripts 包中的命令,该包还包含了 /etc/rc.d/init.d/functions  ,该functions提供了一些基础的函数,经常会被init.d 下的脚本包含; 在centos7上,initscripts 被做了手脚,service命令和functions里面都拦截命令的执行而重定向到systemctl,不过也可以通过环境变量SYSTEMCTL_SKIP_REDIRECT 来禁止重定向,脚本逻辑并不复杂;有时候,我们习惯使用 service 命令,还有时候,我们在docker容器里面使用systemctl总是没有权限,于是,借助环境变量SYSTEMCTL_SKIP_REDIRECT,依然执行 /etc/init.d 下的脚本而不去执行systemctl还是不错的

 Posted by at 下午 12:12

 Leave a Reply

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

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据