From a PHP script I need to get the last system boot time, preferably in the UNIX time stamp format.
Are there any files that are created or modified at boot time? I could read the modified time of the file.
The system type is CentOS.
/proc/uptime
This file contains two numbers: the uptime of the system (seconds), and the amount of time spent in idle process (seconds).
<?php
function get_boottime() {
$tmp = explode(' ', file_get_contents('/proc/uptime'));
return time() - intval($tmp[0]);
}
echo get_boottime() . "\n";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With