电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 1958 人浏览分享

Linux中没有rc.local文件的完美解决方法

[复制链接]
1958 0
这篇文章主要介绍了Linux中没有rc.local文件的解决方法本文给大家介绍的非常详细具有一定的参考借鉴价值,需要的朋友可以参考下
比较新的Linux发行版已经没有rc.local文件了因为已经将其服务化了。
解决方法:
1、设置rc-local.service
  1. sudo vim /etc/systemd/system/rc-local.service
  2. [Unit]
  3. Description=/etc/rc.local Compatibility
  4. ConditionPathExists=/etc/rc.local
  5. [Service]
  6. Type=forking
  7. ExecStart=/etc/rc.local start
  8. TimeoutSec=0
  9. StandardOutput=tty
  10. RemainAfterExit=yes
  11. SysVStartPriority=99
  12. [Install]
  13. WantedBy=multi-user.target
复制代码
2、激活rc-local.service
  1. sudo systemctl enable rc-local.service
复制代码
3、添加启动服务
手工创建或者拷贝已有的/etc/rc.local,并赋予执行权限
  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.
  13. # 下面这条是要开机启动的命令
  14. /home/selfcs/anaconda3/bin/python /home/selfcs/t.py > /home/selfcs/auto.log
  15. exit 0
  16. #给予脚本执行权限
  17. sudo chmod +x /etc/rc.local
复制代码
总结
以上所述是小编给大家介绍的Linux中没有rc.local文件的完美解决方法,希望对大家有所帮助!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

0

粉丝

9021

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.