“Debian rc.local 开机启动问题”的版本间的差异
跳到导航
跳到搜索
小 (导入1个版本) |
|||
第1行: | 第1行: | ||
+ | =debian10= | ||
+ | <pre> | ||
+ | cat <<EOF >/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 | ||
+ | EOF | ||
+ | chmod +x /etc/rc.local | ||
+ | systemctl daemon-reload | ||
+ | systemctl start rc-local | ||
+ | systemctl status rc-local | ||
+ | </pre> | ||
+ | https://stackoverflow.com/questions/44797694/where-is-rc-local-in-debian-9-debian-stretch#44801337 | ||
=Question= | =Question= | ||
leanote 没有做成规范的启动脚本 所以 得加到开机自启动 于是想到 rc.local | leanote 没有做成规范的启动脚本 所以 得加到开机自启动 于是想到 rc.local |
2021年8月17日 (二) 12:32的最新版本
debian10
cat <<EOF >/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 EOF chmod +x /etc/rc.local systemctl daemon-reload systemctl start rc-local systemctl status rc-local
https://stackoverflow.com/questions/44797694/where-is-rc-local-in-debian-9-debian-stretch#44801337
Question
leanote 没有做成规范的启动脚本 所以 得加到开机自启动 于是想到 rc.local
Solution
#一定得加这个启动文件 不然是不行的 cat > /etc/systemd/system/rc-local.service <<EOF [Unit] Description=/etc/rc.local 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 EOF cat <<EOF >/etc/rc.local #!/bin/bash # 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 EOF chmod +x /etc/rc.local systemctl enable rc-local systemctl start rc-local
trouble shooting
#cat /etc/rc.local #这个会导致ssh起不来 可能是因为 有交互内容吧 /data/apps/leanote/bin/run.sh #这个就可以正常启动了哦 /usr/bin/nohup /data/apps/leanote/bin/run.sh &