Here's a code snippet for getting the system boot time in minutes using Python's datetime module.
main.py840 chars24 linesThis script first opens the /proc/stat file and searches for the "btime" line, which contains the system boot time in seconds since epoch. It then converts that to a datetime object using datetime.datetime.fromtimestamp().
The script then calculates the minutes since the last boot by subtracting the boot time from the current time and dividing the result by 60. Finally, it uses the /proc/uptime file to get the system uptime in seconds and converts it to minutes.
gistlibby LogSnag