“Debian rc.local 开机启动问题”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
docker>Evan
 
(导入1个版本)

2019年10月14日 (一) 13:48的版本

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  &