#首先检查rc-local是不是启动了,如果启动最后完全还要restart,这里的坑,sandy踩了半个小时 systemctl status rc-local.service
vim /lib/systemd/system/rc-local.service #最下加入 [Install] WantedBy=multi-user.target Alias=rc-local.service
vim /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. bash /root/start.sh exit 0
#检测服务器是不是已经启动 sudo systemctl status rc-local.service #输出文字,字样就成功启动 Active: active (running) since Fri 2019-06-07 03:25:59 UTC; 19s ago screen -ls #输出文字,字样就成功启动 There is a screen on: 168.baidu (06/08/19 07:14:04) (Detached) 158.google (06/08/19 07:14:04) (Detached) 1 Socket in /run/screen/S-root.