我的问题是:
我有使用 exec 命令生成的大型输出文件。我有大约 800-1500 MB 的文本输出,因为它每秒都附加到我的文本文件中。我怎么能只将最后一条数据写入我的文本文件?
这就是我现在的做法:
$cmd = 'btdownloadheadless --saveas /var/www/virtual/tigyisolutions.hu/boxy/htdocs/downloaded_torrent/'.$kovNev.'/ '.$_REQUEST["torrent"];
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));
我想在我的输出文件中看到这个:
saving: Test torrent (1115.9 MB)
percent done: 19.8
time left: 22 min 04 sec
download to: /var/www/virtual/tigyisolutions.hu/boxy/htdocs/downloaded_torrent/uid1_fil_1370552248/
download rate: 1344.1 kB/s
upload rate: 115.7 kB/s
share rating: 0.121 (26.8 MB up / 221.3 MB down)
seed status: 81 seen now, plus 3.994 distributed copies
peer status: 18 seen now, 45.3% done at 2175.4 kB/s
而不是这个:
saving: Test torrent (1115.9 MB)
percent done: 19.8
time left: 22 min 04 sec
download to: /var/www/virtual/tigyisolutions.hu/boxy/htdocs/downloaded_torrent/uid1_fil_1370552248/
download rate: 1344.1 kB/s
upload rate: 115.7 kB/s
share rating: 0.121 (26.8 MB up / 221.3 MB down)
seed status: 81 seen now, plus 3.994 distributed copies
peer status: 18 seen now, 45.3% done at 2175.4 kB/s
saving: Test torrent (1115.9 MB)
percent done: 19.8
time left: 22 min 04 sec
download to: /var/www/virtual/tigyisolutions.hu/boxy/htdocs/downloaded_torrent/uid1_fil_1370552248/
download rate: 1344.1 kB/s
upload rate: 115.7 kB/s
share rating: 0.121 (26.8 MB up / 221.3 MB down)
seed status: 81 seen now, plus 3.994 distributed copies
peer status: 18 seen now, 45.3% done at 2175.4 kB/s
saving: Test torrent (1115.9 MB)
percent done: 19.8
time left: 22 min 04 sec
download to: /var/www/virtual/tigyisolutions.hu/boxy/htdocs/downloaded_torrent/uid1_fil_1370552248/
download rate: 1344.1 kB/s
upload rate: 115.7 kB/s
share rating: 0.121 (26.8 MB up / 221.3 MB down)
seed status: 81 seen now, plus 3.994 distributed copies
peer status: 18 seen now, 45.3% done at 2175.4 kB/s ...etc...
所以我只想看到最新的屏幕。我的 bash 命令附加输出 txt 而不是重写它。我想重写它。