LoginSignup
0
0

More than 3 years have passed since last update.

フォルダ内のファイル数を定期的にログ出力する

Posted at
watch -n [監視間隔(秒)] 'cnt=`ls -1 [監視対象ディレクトリ] | wc -l`; echo `date "+%Y-%m-%d %H:%M:%S"` ファイル数:${cnt} | tee -a [出力先ファイルログ名]'

例:1秒間隔で「/home/hoge」ディレクトリのファイル数を「/home/fuga.log」というファイルに出力する。

watch -n 1 'cnt=`ls -1 /home/hoge | wc -l`; echo `date "+%Y-%m-%d %H:%M:%S"` ファイル数:${cnt} | tee -a /home/fuga.log'
0
0
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
0