赞
踩
1、创建运行脚本,以管理员放方式运行,加入密码
vim runapp.sh
#!/bin/bash
cd /home/nvidia/test
echo ‘passcode’ | sudo -S ./testapp
2、终端输入
gnome-session-properties
3、在command输入执行脚本命令 sh /home/nvidia/runapp.sh
4、在 home/nvidia/.config 目录下就会生成autostart文件夹,内部存有对应的.desktop文件夹,查看文件内容
- #!/bin/bash
- sleep 3
- echo “pwm fan start”
- sudo /usr/bin/jetson_clocks
- sudo sh -c 'echo 100 > /sys/devices/pwm-fan/target_pwm'
- echo “success”
-
- exit 0
- [Unit]
- Description=start pwm fan
- #After=default.target
-
- [Service]
- Type=forking
- ExecStart=/etc/auto_start/pwm_fan.sh
- Restart=on-failure
- RestartSec=3s
-
- [Install]
- WantedBy=multi-user.target
- sudo mv pwm_fan.service /etc/systemd/system/
- sudo systemctl enable pwm_fan.service
- sudo service pwm_fan.service
-
参考资料:
Linux之service服务-实现程序脚本开机自启_linux service 开机自启_xiaohai@Linux的博客-CSDN博客
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。