0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dmesgで出力されるシステムログにログをリダイレクトする

Posted at

dmesgの出力ログに何らかのログを追加する場合、/dev/kmsgにリダイレクトするとよい

$ echo "TESTLOG" > /dev/kmsg
$ dmesg | tail -1
[7216583.480456] TESTLOG

リダイレクト時に権限エラーが出力された場合は、tee -a を用いるとよい

$ echo "TESTLOG" > /dev/kmsg
/dev/kmsg: 許可がありません
$ echo "TESTLOG" | sudo tee -a /dev/kmsg > /dev/null
$ dmesg | tail -1
[7216705.651341] TESTLOG

参考

システムログ1
sudoでリダイレクトするとエラーが出た時の解決法

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?