UBUNTU18.04 中已经不能使用rc.local
可以通过添加启动服务的方式
感谢
https://blog.youkuaiyun.com/qq_14852397/article/details/71794574?locationNum=11&fps=1
http://www.r9it.com/20180613/ubuntu-18.04-auto-start.html
https://blog.youkuaiyun.com/chwshuang/article/details/68489968
假如你要建立的服务名为 aaa
1.在 /etc/下建立要启动的脚本 aaa.sh
脚本中最好添加 输出测试
echo "ceshi" > /home/xxxx/Documents/xxxx.log
2.在 /lib/systemd/system下建立 aaa.service
输入
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server /usr/local/redis/redis.conf --daemonize no
ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
[Install]
WantedBy=multi-user.target
ExecStart=你的执行命令或者脚本
ExecStop=可写可不写
3.添加启动
systemctl start redis
4. 刷新配置
systemctl daemon-reload
5. 执行
sudo systemctl start aaa
6.如果文本成功写入则成功,reboot开机测试一下