[Topic DIscussion] 怎么实现系统启动自动执行自己编写的.sh文件
Tofloor
poster avatar
dgmenghuan
deepin
2022-05-28 06:23
Author

今天困扰了我一整天也没有弄明白,还请各路大神帮我一下,谢谢!

我用uwsgi+nginx+django做了一个小程序,可以实现局域网内自由访问,但每次使用的时候就得输入

uwsgi --ini /home/mysite/myapp.ini

sudo /home/mysite/nginx/sbin/./nginx

这两条语句,太麻烦了,上网找了N圈,在/etc/init.d/放入.sh文件就能自动执行,用chkconfig指定执行方式:

chkconfig -add mysite.sh

chkconfig -level 2345 mysite.sh on

输入完毕,sudo reboot等着重启后,以前啥样重启后还是啥样,愁死了,望各路大神帮我一下,万分感谢,最好说的详细一些

Reply Favorite View the author
All Replies
神末shenmo
deepin
Spark-App
Q&A Team
2022-05-28 06:33
#1

写一个service可以

https://gitee.com/deepin-community-store/spark-store/blob/master/pkg/usr/lib/systemd/system/spark-update-notifier.service

参考这个

或者你写个autostart

用echo "密码" | sudo -S xxxxxx写到exec=后面

desktop可以参考 https://gitee.com/deepin-community-store/spark-store/blob/master/tool/update-upgrade/autostart/spark-update-notifier.desktop

位置在~/.config/autostart​或者/etc/xdg/autostart/​时启动会执行

Reply View the author
送你的鱼
deepin
2022-05-28 07:51
#2

~/.config/autostart

Reply View the author
ltree
deepin
2022-05-28 16:35
#3
It has been deleted!
SamLukeYes
deepin
2022-05-28 19:59
#4

/etc/init.d 是前 systemd 时代的东西了,而 deepin 现在是用 systemd 的,所以现在应该像版主举的第一个例子一样用 systemd service。不需要 root 权限的程序也可以用 autostart。

Reply View the author