I have written a Python program to restart the server running on Ubuntu 18.04 using: os.system("shutdown -r -t 1").
When the service is loaded the program OS is not restarting, but on the independent running of the program it is working fine.
The service log shows:
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.Whats going wrong?
1 Answer
The shutdown command requires elevated privileges.
Imagine, in a multi user environment, which a Linux system is, every logged in user could shutdown or reboot the machine - this would be fatal.
So, basically you need to get elevated privileges.
This question has been answered many times. Here is a good thread: