I\'m looking for a fast and lightweight way to read system uptime from a Python script. Is there a way to call the sysinfo Linux system call from Python?
sysinfo
This frankly seems like a much better solution:
def get_uptime(): with open('/proc/uptime', 'r') as f: uptime_seconds = float(f.readline().split()[0]) return uptime_seconds
It also has the added benefit of not requiring any additional modules.
Credits: Source