您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何在Gentoo Linux上设置启动和关闭脚本

2024/7/10 6:38:43发布22次查看
有时需要在系统启动和关闭期间运行命令或shell脚本。这有助于在系统启动时启动服务,并在系统关闭时停止服务。本篇文章将介绍关于在gentoo linux上运行系统启动和关闭脚本。
现在/etc/local.d/目录中带有后缀.start的脚本将在系统启动时执行,所有带有后缀.stop的脚本将在系统关闭期间执行。首先确保使用以下步骤启用了local.d脚本。
启用local.d脚本
要在引导时启动local.d脚本,请将其init.d脚本添加到默认运行级别
# rc-update add local default
现在,通过在默认运行级别中对已停止的服务执行openrc检查来启动服务:
# rc-service local start
启动时运行脚本
创建一个脚本/etc/local.d/myservice.start并将你的内容放入其中。这将在系统引导期间执行。
# vi /etc/local.d/myservice.start
#!/bin/sh# show below message on system startupecho "welcome back!"
关闭时运行脚本
创建一个脚本/etc/local.d/myservice.stop并将你的内容放入其中。这将在系统关闭期间执行。
# vi /etc/local.d/myservice.stop
#!/bin/sh# show below message on system shutdownecho "good bye!
本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注的linux视频教程栏目!
以上就是如何在gentoo linux上设置启动和关闭脚本的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product