ubuntu下rc.local不执行

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu 22.04中,如果你想要将一个程序添加到开机启动中,你可以通过修改rc.local文件来实现。在Ubuntu中,有两个rc.local文件,分别是/etc/rc.local和/etc/init.d/rc.local。这两个文件有一定的关联关系。 如果你在系统中找不到这两个文件,你可以自己创建一个rc-local.service文件,并在其中添加以下内容: [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target 然后,你可以启动rc-local.service服务并将其设置为开机自启: sudo systemctl start rc-local.service sudo systemctl enable rc-local.service 最后,你可以创建/etc/rc.local文件,并将以下内容复制粘贴到文件中: #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0 记得给予脚本执行权限。通过以上步骤,你可以将程序添加到Ubuntu 22.04的rc.local中,并实现开机启动。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu系统中/etc/rc.local和/etc/init.d/rc.local的区别详解](https://download.csdn.net/download/weixin_38564826/14890316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [ubuntu没有rc.local文件](https://blog.csdn.net/qq_35002542/article/details/127999561)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值