openEuler欧拉使用rc.local实现开机自启动

  1. ​设置权限
    chmod 775 /etc/rc.local

  2. 普通的单条是,直接写在rc.local里
    /usr/local/nacos/bin/startup.sh -m standalone

  3. 复杂点的,带nohup这种的,写个shell,然后chmod 775
    例如:/root/startrocketmq.sh

#!/bin/bash
nohup sh  /root/rocketmq-all-4.8.0-bin-release/bin/mqbroker -n ip地址:端口号 &
  1. 完整的rc.local 如下:
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
/usr/local/nacos/bin/startup.sh  -m standalone
/root/startrocketmq.sh

番外篇:Docker设置自启动

在docker run最后一句引用image之前,加上 --restart=always
如:

docker run -d -v /data/mysql/data:/var/lib/mysql -v /data/mysql/conf:/etc/mysql/conf.d --name mysql -e TZ=Asia/Shanghai  -e MYSQL_ROOT_PASSWORD=密码 -p 3306:3306 --restart=always mysql
posted @ 2024-01-08 11:40  李济宏(Amadeus)  阅读(892)  评论(0编辑  收藏  举报