###前提・実現したいこと
実行中のコマンドを指定した時間に終了させる方法を知りたいです.
よろしくお願いします.
・2>/dev/null | tee file_name
で表示しつつリダイレクト(で保存)させたい
・指定した時間後に終了させたい
です
###試したこと
「ping」が止まらない|DesktopなLinuxの設定とか でpingの止め方は紹介されているので
pingコマンドを5秒後に終了させたい訳ではないのですが,
近い現象が起こっているので,pingコマンドを例として質問させていただいています.
$ (sleep 5;kill $$)& exec ping www.example.com 2>/dev/null | tee ping
と実行してみたのですが,
$ (sleep 5;kill $$)& exec ping www.example.com 2>/dev/null | tee ping
[1] 16678
PING www.example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=53 time=164.406 ms
64 bytes from 93.184.216.34: icmp_seq=1 ttl=53 time=114.848 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=53 time=171.055 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=53 time=172.242 ms
64 bytes from 93.184.216.34: icmp_seq=4 ttl=53 time=164.921 ms
64 bytes from 93.184.216.34: icmp_seq=5 ttl=53 time=115.383 ms
64 bytes from 93.184.216.34: icmp_seq=6 ttl=53 time=113.631 ms
64 bytes from 93.184.216.34: icmp_seq=7 ttl=53 time=141.498 ms
64 bytes from 93.184.216.34: icmp_seq=8 ttl=53 time=113.248 ms
64 bytes from 93.184.216.34: icmp_seq=9 ttl=53 time=145.504 ms
64 bytes from 93.184.216.34: icmp_seq=10 ttl=53 time=176.518 ms
64 bytes from 93.184.216.34: icmp_seq=11 ttl=53 time=121.876 ms
^C(止まらなかったため自分でCtrl+Cで終了させました.)
[1]+ Done ( sleep 5; kill $$ )
$ cat ping
PING www.example.com (93.184.216.34): 56 data bytes
64 bytes from 93.184.216.34: icmp_seq=0 ttl=53 time=164.406 ms
64 bytes from 93.184.216.34: icmp_seq=1 ttl=53 time=114.848 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=53 time=171.055 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=53 time=172.242 ms
64 bytes from 93.184.216.34: icmp_seq=4 ttl=53 time=164.921 ms
64 bytes from 93.184.216.34: icmp_seq=5 ttl=53 time=115.383 ms
64 bytes from 93.184.216.34: icmp_seq=6 ttl=53 time=113.631 ms
64 bytes from 93.184.216.34: icmp_seq=7 ttl=53 time=141.498 ms
64 bytes from 93.184.216.34: icmp_seq=8 ttl=53 time=113.248 ms
64 bytes from 93.184.216.34: icmp_seq=9 ttl=53 time=145.504 ms
64 bytes from 93.184.216.34: icmp_seq=10 ttl=53 time=176.518 ms
64 bytes from 93.184.216.34: icmp_seq=11 ttl=53 time=121.876 ms
よろしくお願いします.
###補足情報(言語/FW/ツール等のバージョンなど)
MacOSX Sierra 10.12.6
Ubuntu16.04LTS
では実行できました.
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/08 07:49
2017/08/08 08:12
2017/08/08 09:09
2017/08/08 10:15
2017/08/08 22:14