{"id":2513,"date":"2016-02-03T17:05:50","date_gmt":"2016-02-03T17:05:50","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=2513"},"modified":"2016-02-03T17:07:33","modified_gmt":"2016-02-03T17:07:33","slug":"reboot","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/software_utilities\/web-servers\/php-code-bits\/reboot","title":{"rendered":"Reboot"},"content":{"rendered":"<h4>\nReboot From PHP Page<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n&lt;?php\r\n\t\/\/----- DO THE REBOOT -----\r\n\t\t\/\/THIS SUDO COMMAND NEEDS TO BE AUTHORISED FOR APACHE TO USE IT IN THE FILE: sudo nano \/etc\/sudoers\r\n\t\t\/\/\t# Special for this system - let apache run exes we use in the web interface\r\n\t\t\/\/\twww-data ALL=NOPASSWD: \/sbin\/reboot\r\n\techo &#39;&lt;pre&gt;&#39;;\r\n\tsystem(&quot;(sleep 2 ; sudo \/sbin\/reboot ) &gt; \/dev\/null 2&gt;&amp;1 &amp; echo $!&quot;);\r\n\techo &#39;&lt;\/pre&gt;&#39;;\r\n?&gt;\r\n<\/code><\/pre>\n<p>\nThe sleep causes a 2 second delay before its actions.\n<\/p>\n<p>\nThe &quot;&gt; \/dev\/null 2&gt;&amp;1 &amp; echo $!&quot; causes the system command to return immediately and for the command to be issued in the background, allowing the page to load before the reboot&nbsp;actually occurs.\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reboot From PHP Page &lt;?php \/\/&#8212;&#8211; DO THE REBOOT &#8212;&#8211; \/\/THIS SUDO COMMAND NEEDS TO BE AUTHORISED FOR APACHE TO USE IT IN THE FILE: sudo nano \/etc\/sudoers \/\/ # Special for this system &#8211; let apache run exes we use in the web interface \/\/ www-data ALL=NOPASSWD: \/sbin\/reboot echo &#39;&lt;pre&gt;&#39;; system(&quot;(sleep 2 ; sudo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[],"class_list":["post-2513","post","type-post","status-publish","format-standard","hentry","category-php-code-bits"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=2513"}],"version-history":[{"count":3,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2513\/revisions"}],"predecessor-version":[{"id":2516,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/2513\/revisions\/2516"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=2513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=2513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=2513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}