電源を入れてから時間を取得します。

電源を入れてから時間を取得します。

Linuxを起動するときに特定の内容をロードするタイムスタンプなどがあるので、いつ起動が始まったのかについての情報が必要だと思います。たとえば、いつでもコマンドを実行したり、開始までに数秒を表示したりする方法はありますか10.3452232

busybox initシステムで動作する必要があります。

ベストアンサー1

あなたが探しているようです/proc/uptime。これはLinuxカーネルに組み込まれているため、すべてのシステムで動作します。

マニュアルから:https://man7.org/linux/man-pages/man5/proc.5.html

/proc/uptime
          This file contains two numbers (values in seconds): the uptime
          of the system (including time spent in suspend) and the amount
          of time spent in the idle process.

これを簡単な方法で読むことができます:

cat /proc/uptime

またはスクリプトから:

read uptime idle < /proc/uptime
echo $uptime

おすすめ記事