commandの頭にタイムスタンプを付ける

複数行出力するコマンドにタイムスタンプを付ける

 メモリー情報を1秒ごとに出力するコマンドにタイムスタンプを付ける

# free -h -s 1

              total        used        free      shared  buff/cache   available

Mem:            31G        4.5G         17G        7.2G        9.2G         19G

Swap:           15G          0B         15G

              total        used        free      shared  buff/cache   available

Mem:            31G        4.5G         17G        7.2G        9.2G         19G

Swap:           15G          0B         15G

# free -h -s 1 | gawk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0 }'
[2022-11-29 21:36:22]               total        used        free      shared  buff/cache   available
[2022-11-29 21:36:22] Mem:            31G        4.5G         17G        7.2G        9.1G         19G
[2022-11-29 21:36:22] Swap:           15G          0B         15G
[2022-11-29 21:36:23]
[2022-11-29 21:36:23]               total        used        free      shared  buff/cache   available
[2022-11-29 21:36:23] Mem:            31G        4.5G         17G        7.2G        9.1G         19G
[2022-11-29 21:36:23] Swap:           15G          0B         15G

コメント

人気の投稿