Home:ALL Converter>How to shutdown and then reboot linux machine using python Language or shell script?

How to shutdown and then reboot linux machine using python Language or shell script?

Ask Time:2016-02-22T13:40:05         Author:Asif Ali S

Json Formatter

Am trying to shutdown and boot it again the Linux system using python language or shell script. can anyone clarify me in this ? even crontab is also okay

Author:Asif Ali S,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/35546497/how-to-shutdown-and-then-reboot-linux-machine-using-python-language-or-shell-scr
zydcom :

shell\n\nreboot\n\n\npython\n\nimport os\nos.system('reboot')\n\n\nNote: You need root permission to do reboot operation.\n\nYou should take some time to learn Linux basic concepts first.",
2016-02-22T06:02:55
Julien JEHL :

You need two things to make your linux system to reboot.\n\n1 - Give the user executing your script the privilege for reboot\n\n$ sudo visudo -f /etc/sudoers.d/reboot_privilege\n\nadd line :\n\n<user> ALL=(root) NOPASSWD: /sbin/reboot\n\n2 - Execute the python code :\n\nimport os\nos.system(\"sudo reboot\")\n\n\nIt will reboot your system without any prompt nor check password.",
2020-06-09T16:08:37
yy