Bash
bash : 使用 notify-send 發送 rsync 狀態
我
rsync
用來將一些更改推送到伺服器,為此我製作了一個 bash 腳本,並且我想在桌面上顯示狀態通知(我使用的是 Linux Mint 18 Cinnamon)是否可以發送 to 的輸出,
rsync
以便notify-send
我可以看到同步的數據量?這是我的實際 bash 腳本:notify-send "sincronizando esteticas" rsync -tprvkku --exclude "00_docs" --exclude "temp" --exclude "config.php" --progress public_html/ rsync://myserver:/myfiles notify-send "sincronizacion terminada"
如果您想要一個包含最終摘要行的通知彈出視窗,例如
sent 6,673,231 bytes received 17,718 bytes 13,381,898.00 bytes/sec total size is 6,613,892 speedup is 0.99
然後您可以將 rsync 輸出擷取到一個文件中,並使用該文件的最後 2 行:
rsync ... | tee /tmp/out notify-send "$(tail -2 /tmp/out)"
如果您想要更詳細的摘要,請添加
--info=stats2
rsync --info=stats2 ... | tee /tmp/out notify-send "$(tail -16 /tmp/out)"
這將提供額外的資訊,例如:
Number of files: 932 (reg: 929, dir: 2, link: 1) Number of created files: 932 (reg: 929, dir: 2, link: 1) Number of deleted files: 0 Number of regular files transferred: 929 Total file size: 6,613,892 bytes Total transferred file size: 6,613,888 bytes Literal data: 6,613,888 bytes Matched data: 0 bytes File list size: 0 File list generation time: 0.001 seconds File list transfer time: 0.000 seconds Total bytes sent: 6,673,231 Total bytes received: 17,686