ayy*_*emi 2 windows command-line uptime
如何从 Windows 命令行以毫秒为单位获得系统正常运行时间?我想要类似这个函数的结果:gettickcount()
,例如24233241231
。
是否有此命令、实用程序或技巧?
小智 5
您确定需要通过命令行实用程序获得毫秒数。恕我直言,启动一个新进程来获取它的开销将需要一点时间。
如果秒也符合您的要求,这里有一些 bash 代码的小纲。
进一步的假设是你有某种unix。此示例适用于当前的 linux 系统。
# Reading the time of boot
bootTime=$(awk '/^btime/{print $2;}' </proc/stat)
currentTime=$(date +%s)
liveTime=$(( ${currentTime} - ${bootTime} ))
echo "online since: ${liveTime}"
Run Code Online (Sandbox Code Playgroud)