Debian rc.local 开机启动问题

来自linux中国网wiki
docker>Evan2018年11月9日 (五) 02:35的版本 →‎Solution
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

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  &