0
0

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.

毎日9時から17時までtcpdumpでパケットキャプチャしてファイルに書き出す方法

Posted at

tcpdumpのログをファイルに書き出す

tcpdump -w /path/to/`date "+%Y%m%d%H%M%S"`.pcap

保存するファイル名は日時

指定した時間の間tcpdumpを実行する

sudo timeout {時間} tcpdump

timeoutコマンドを用いて任意の時間の間tcpdumpを実行する。時間はデフォルトで秒。時間の後ろにs(秒)、m(分)、h(時)、d(日)をつけることで単位を指定できる。

tcpdumpを定期実行する

crontab -e

crontabコマンドを用いて、定期的にジョブを実行するようスケジュールするcronを設定する

{} {} {} {} {曜日} /usr/sbin/tcpdump

指定しないなら*、例えば毎日AM9:00に実行したいなら、

0 9 * * * /usr/sbin/tcpdump

毎日9時から17時までパケットキャプチャしてファイルに書き出す

0 9 * * * timeout 8h /usr/sbin/tcpdump -w /path/to/`date "+%Y%m%d%H%M%S"`.pcap

cronに上記の設定をする

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?