[Topic DIscussion] 怎么实现在关机前执行某一个脚本 Resolved
Tofloor
poster avatar
deepin-chinaren
deepin
2022-08-29 16:24
Author

怎么实现在关机前执行某一个脚本,请大佬们指教?先谢谢了!

Reply Favorite View the author
All Replies
zijinyise
deepin
2022-08-29 16:52
#1

机智一下,创建个关机命令,前面代码首先执行你的脚本,然后执行关机

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2022-08-29 16:58
#2

应该是service可以做到吧

具体没查...(

Reply View the author
deepin-chinaren
deepin
2022-08-29 17:11
#3
神末shenmo

应该是service可以做到吧

具体没查...(

能否具体一点

Reply View the author
liwl
deepin
2022-08-29 17:42
#4

我感觉是没有的,否则我可以写个脚本,在关机前拒绝关机

like

Reply View the author
Feng Yu
deepin
2022-08-29 17:43
#5

https://opensource.com/life/16/11/running-commands-shutdown-linux

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2022-08-29 17:44
#6

service文件中写

[Install]
WantedBy=poweroff.target
WantedBy=reboot.target
WantedBy=halt.target

教程如下

http://www.yuanchengzhushou.cn/article/8241.html

Reply View the author
deepin-chinaren
deepin
2022-08-29 18:07
#7
神末shenmo

service文件中写

[Install]
WantedBy=poweroff.target
WantedBy=reboot.target
WantedBy=halt.target

教程如下

http://www.yuanchengzhushou.cn/article/8241.html

截图_选择区域_20220829100447.png

cust_shut.service在deepin系统是不存在的

截图_选择区域_20220829100716.png

Reply View the author
安洛
deepin
2022-08-29 18:12
#8
deepin-chinaren

截图_选择区域_20220829100447.png

cust_shut.service在deepin系统是不存在的

截图_选择区域_20220829100716.png

这个cust-shut其实是这个教程作者举的一个例子,你用自己想要运行的东西替换掉就行。它这里没讲明白。

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2022-08-29 18:22
#9
deepin-chinaren

截图_选择区域_20220829100447.png

cust_shut.service在deepin系统是不存在的

截图_选择区域_20220829100716.png

这是让你自己写一个service,这只是他的例子

Reply View the author
deepin-chinaren
deepin
2022-08-29 19:25
#10
神末shenmo

这是让你自己写一个service,这只是他的例子

截图_选择区域_20220829111812.png用那个圈里的文件来改写service文件?

Reply View the author
deepin-chinaren
deepin
2022-08-29 20:22
#11
deepin-chinaren

截图_选择区域_20220829111812.png用那个圈里的文件来改写service文件?

用下面的方法可以实现

https://blog.csdn.net/weixin_44832060/article/details/115466429?spm=1001.2101.3001.6650.10&utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10-115466429-blog-78680021.pc_relevant_multi_platform_whitelistv3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10-115466429-blog-78680021.pc_relevant_multi_platform_whitelistv3&utm_relevant_index=14

Reply View the author
Ziggy
deepin
2022-08-30 01:39
#12

没这么麻烦,写个crontab,在关机时间之前再加个操作就行了,非重叠时间和先后顺序

Reply View the author