Linux下Qt程序设置system服务开机自启

1、执行

> /home/firefly/.config/lxsession/Lubuntu/autostart

2、执行

crontab -e

修改

10 * * * * /bin/bash /opt/restart_bluetoothdemo.sh &> /dev/null

10 * * * * /bin/systemctl restart ble-gw

3、执行

vim /etc/systemd/system/ble-gw.service

复制下面文本

[Unit]
Description=Start Bluetooth Gateway Application after Network
After=network.target,systemd-resolved.service
Wants=network.target,systemd-resolved.service

[Service]
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/1000
Environment=PULSE_RUNTIME_PATH=/run/user/1000/pulse/
Environment = LD_LIBRARY_PATH=/opt/Qt/5.15.14_armhf/lib:/usr/local/lib
Environment = QT_PLUGIN_PATH=/opt/Qt/5.15.14_armhf/plugins
Environment = PATH=$PATH:/opt/Qt/5.15.14_armhf/bin
ExecStartPre=/bin/sleep 15
ExecStart=/home/firefly/Downloads/build-bluetoothdemo-unknown-Release/bluetoothdemo
WorkingDirectory=/home/firefly/Downloads/build-bluetoothdemo-unknown-Release/
Restart=always
User=firefly

[Install]
WantedBy=multi-user.target

按键盘字母i,然后鼠标右键粘贴

然后按键盘输入冒号,再输入小写wq,回车

4、设置ble-gw开机自启

systemctl enable ble-gw

5、关闭系统日志服务

systemctl disable --now systemd-journald.service
systemctl disable --now syslog.socket rsyslog.service

6、开启dhcp自动续约:在配置文件中,添加或修改以下行:

vim /etc/dhcp/dhclient.conf
# 启用自动续约
request-renewal-time=60
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值