LoginSignup
46
39

More than 5 years have passed since last update.

/var/log/のログファイルを一括でクリアしたくなったら

Posted at

お客様のサーバなんかを構築した後に綺麗な状態で納品したくて特定ファイル(今回は/var/log)のファイルを一括消去したくて方法を模索したのでシェアします。

ファイルを削除ではなく、ファイルの中身を消去を目的をしています。

[centos@root ~]# find /var/log/ -type f -name \* -exec cp -f /dev/null {} \;

これで/var/log以下のファイルを探しだし、すべてのファイルに対して/dev/nullでnullを書き込んでいます。

一般的なLinuxサーバであれば利用出来るコマンドなのでお試しアレ。

46
39
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
46
39