首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未能通过运行在服务中的Python程序重新启动操作系统

未能通过运行在服务中的Python程序重新启动操作系统
EN

Ask Ubuntu用户
提问于 2019-11-18 07:27:16
回答 1查看 808关注 0票数 0

我编写了一个Python程序,使用:os.system("shutdown -r -t 1")重新启动运行在Ubuntu18.04上的服务器。

当服务被加载时,程序操作系统不会重新启动,但是在程序独立运行时,它工作正常。

服务日志显示:

代码语言:javascript
复制
Nov 18 12:51:51 jetson-desktop python3[13004]: Failed to set wall message, ignoring: Interactive authentication required.
Nov 18 12:51:51 jetson-desktop python3[13004]: Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.
Nov 18 12:52:44 jetson-desktop python3[13004]: Failed to set wall message, ignoring: Interactive authentication required.
Nov 18 12:52:44 jetson-desktop python3[13004]: Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: Interactive authentication required.

出什么事了?

EN

回答 1

Ask Ubuntu用户

发布于 2019-11-18 07:57:52

shutdown命令需要提升特权。

想象一下,在Linux系统的多用户环境中,每个登录用户都可能关闭或重新启动机器--这将是致命的。

所以,基本上你需要获得更高的特权。

这个问题已经回答了很多次了。下面是一个很好的线索:

https://stackoverflow.com/questions/25215604/use-sudo-without-password-inside-a-script

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1189696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档