Linux开机自动启动服务

Linux开机自动启动服务,第1张

概述当我们的Linux,关机后,或者重启后,有些服务需要人工启动才能有。为了解决这个问题,我找了一个办法,用一个脚本,开机启动想启动的服务。 1 cd /etc/rc.d/init.d/ 进入该文件夹2 vi auto.sh 编写脚本3 chmod +x auto.sh 给脚本添加执行权限4 chkconfig --add auto.sh 添加

当我们的linux,关机后,或者重启后,有些服务需要人工启动才能有。为了解决这个问题,我找了一个办法,用一个脚本,开机启动想启动的服务。

1 cd /etc/rc.d/init.d/     进入该文件夹2 vi auto.sh        编写脚本3 chmod +x auto.sh        给脚本添加执行权限4 chkconfig --add auto.sh      添加脚本至开机自启5 chkconfig auto.sh on     开启6 reboot        重启

auto.sh中

 1 #!/bin/sh 2  3 #auto.sh log 4 DIR=/var/log 5 LOGfile=auto_start_log.txt 6 echo start system  `date "+%Y-%m-%d %H:%M:%s"` >> $DIR/$LOGfile 7  8 # auto service 9 systemctl restart firewalld.service10 echo  `date "+%Y-%m-%d %H:%M:%s"`  restart firewalld  >> $DIR/$LOGfile
VIEw Code

 

参考:

https://blog.csdn.net/softwarenb/article/details/80275479

https://www.cnblogs.com/xianhaiyan/p/7650391.html

https://blog.csdn.net/jk110333/article/details/8590746/

cd /etc/rc.d/init.d/ 进入该文件夹vi auto.sh 编写脚本chmod +x auto.sh 给脚本添加执行权限chkconfig --add auto.sh  添加脚本至开机自启chkconfig auto.sh on 开启reboot 重启

总结

以上是内存溢出为你收集整理的Linux开机自动启动服务全部内容,希望文章能够帮你解决Linux开机自动启动服务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1017220.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存