linux 开机启动应用(未登录就启动在后台)

复制 /usr/bin/startx 脚本到自定义位置,比如 /root/start_app.sh,在 xinit "$client" $clientargs -- "$server" $display $serverargs上面添加:

client="/root/vite-electron-0.0.0-arm64.AppImage"
clientargs="-m --no-sandbox" # 自定义的参数

添加权限:chmod 777 /root/start_app.sh


开机自启动脚本,/etc/init.d/poweron_start.sh:

#!/bin/bash

### BEGIN INIT INFO
# Provides:          XXX
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start XXX daemon at boot time
# Description:       Start XXX daemon at boot time
### END INIT INFO

/root/start_app.sh &

需要这些注释,不然 systemctl 报错
添加权限:chmod 777 /etc/init.d/poweron_start.sh


使能开机启动

systemctl enable poweron_start.sh

你可能感兴趣的:(linux,linux,chrome,运维)