# boot time in /proc/stat isn't constant - alternatives?

## fikiz

Hello everybody.

I realized that the btime value in /proc/stat isn't constant. Every now and then it drifts forward 1 second at a time. 

Searching on the net, I found people complaining about that since Linux 2.2 so... It must be ok and I don't look for bug fixes or whatever. I would be fun know why this drift happens, but it's not my point.

What I'm looking for is a reliable way to identify reboots inside a script launched by cron. It's easy, I can write the btime value down into a file once at every boot and read that file from my script.

But here I would like the simplest possible solution: get this information directly from the OS or the kernel. There is something somewhere inside /proc or /sys that it changes at every boot and stays constant until the next reboot?

Thanks for any hint.

bye

----------

## szatox

It seems you're looking for this:

```
uptime -s
```

----------

## fikiz

szatox:

I took my time to check uptime -s stability, but it suffers a slow drift too, albeit not the same as btime in /proc/stat.

I also realized that the drift is somehow related to suspend/resume cycles.

Thank you anyway.

----------

## szatox

Good point, now as you mentioned it I checked it as well, and the boot time suddenly got delayed by 1 second.

However, you can still do that in the simple and ugly way: create a timestamp file under /run during boot process.

A 1 line script in /etc/local.d/ will do the trick.

----------

