0

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 1

0

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:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .