You could do:

expr `date +%s` - `sysctl -n kern.boottime`




On Fri, 20 Mar 2020 at 12:54, Alex Naumov <[email protected]> wrote:
>
> Hi,
>
> this patch adds a new option to uptime(1) that allows to see the length of
> time the system has been up in seconds.
> Patch includes documentation (man-page) update.
>
> Example:
> $ uptime
>  1:26PM  up  1:28, 1 user, load averages: 0.00, 0.00, 0.00
> $ uptime -S
>  1:26PM  5308 secs, 1 user, load averages: 0.00, 0.00, 0.00
>
> It's tested in current on amd64 and aarch64.
>
> Why I need it? Well, it makes it easy to check the time the system has been
> up, for example, via scripts. It doesn't need to parse the output and
> recalculate it.
>
> Cheers,
> Alexander

Reply via email to