我编写了一个Python程序,使用:os.system("shutdown -r -t 1")重新启动运行在Ubuntu18.04上的服务器。
当服务被加载时,程序操作系统不会重新启动,但是在程序独立运行时,它工作正常。
服务日志显示:
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.出什么事了?
发布于 2019-11-18 07:57:52
shutdown命令需要提升特权。
想象一下,在Linux系统的多用户环境中,每个登录用户都可能关闭或重新启动机器--这将是致命的。
所以,基本上你需要获得更高的特权。
这个问题已经回答了很多次了。下面是一个很好的线索:
https://stackoverflow.com/questions/25215604/use-sudo-without-password-inside-a-script
https://askubuntu.com/questions/1189696
复制相似问题