php - Get system startup time (without reading /proc/uptime) -


i cannot open /proc/uptime due open_basedir restriction.

the command uptime old , doesn't have -s flag support.

how can - in php - time when server started?

my current code this, not work on production server (for reasons mentioned above):

public static function getboottime() {     $tmp = explode(' ', file_get_contents('/proc/uptime'));     return ((int) ((time() - intval($tmp[0])) / 10)) * 10; } 

you don't need -s flag determine uptime. if have time server running:

$tmp = explode(' ', exec('uptime')); $uptime = $tmp[2]; // 2:14 (hh:mm) 

nb: alternative use who -b command, print out last system boot time.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -