Skip to content

Instantly share code, notes, and snippets.

@mz0
Last active July 5, 2018 12:41
Show Gist options
  • Save mz0/e5bd34e287862f1963dfb014f93ce4a0 to your computer and use it in GitHub Desktop.
Save mz0/e5bd34e287862f1963dfb014f93ce4a0 to your computer and use it in GitHub Desktop.
monitor disk-copy progress (Unix/macOS)
Total=2695716
BW=28.5
Last=0
while true; do
echo -n $(date +%H:%M:%S.%N); # %N - nanoseconds, GNU 'date' only
Curr=$(df -m /dev/sdd1 |grep sdd1|awk '{print $3}');
Remain=$(expr "$Total" - "$Curr")
TtRun=$(echo "(($Remain / $BW) +0.5)/1" | bc)
ETA=$(date --date="+ $TtRun seconds") # GNU 'date' only
echo ' '$Curr' +'$(expr "$Curr" - "$Last") MB "; ETA: $ETA (@ $BW MBps)"
Last=$Curr
sleep 100; # debug with 'sleep 1', use 10,100 for better BW estimates
done
linux $ . cprogress # rsync over ssh from Macbook to USB3-attached HDD
11:31:17.157009569 137309 +137309 MB ; ETA: Sat Apr 28 12:27:25 MSK 2018 (@ 28.5 MBps)
11:32:57.193349436 140155 +2846 MB ; ETA: Sat Apr 28 12:27:25 MSK 2018 (@ 28.5 MBps)
11:34:37.223771446 143003 +2848 MB ; ETA: Sat Apr 28 12:27:25 MSK 2018 (@ 28.5 MBps)
^C
mac $ . cprogress # local copy via USB2-port
13:36:19 257993 +257993 MB ; ETA: Sun Apr 29 00:19:50 MSK 2018 (@ 19.5 MBps)
13:38:00 259976 +1983 MB ; ETA: Sun Apr 29 00:19:49 MSK 2018 (@ 19.5 MBps)
13:39:40 261988 +2012 MB ; ETA: Sun Apr 29 00:19:46 MSK 2018 (@ 19.5 MBps)
..
17:12:19 513716 +2054 MB ; ETA: Sun Apr 29 00:17:16 MSK 2018 (@ 19.5 MBps) # looks like it makes > 19.5 MBps
17:14:00 515669 +1953 MB ; ETA: Sun Apr 29 00:17:17 MSK 2018 (@ 19.5 MBps) # but not much: < 3 minutes delta this far
..
Copy speed estimate: 19.65 MBps
23:42:58 2661309 +2014 MB ; ETA: Sun Apr 29 00:12:08 MSK 2018
23:44:38 2663322 +2013 MB ; ETA: Sun Apr 29 00:12:06 MSK 2018
23:46:18 2665252 +1930 MB ; ETA: Sun Apr 29 00:12:08 MSK 2018
23:47:58 2667304 +2052 MB ; ETA: Sun Apr 29 00:12:03 MSK 2018
..
00:08:04 2690857 +1954 MB ; ETA: Sun Apr 29 00:12:11 MSK 2018
00:09:44 2692307 +1450 MB ; ETA: Sun Apr 29 00:12:37 MSK 2018
00:11:24 2692307 +0 MB ;
Total=2695716
Last=0
Target='/Volumes/Seagate2T8'
BW=19.65
echo "Copy speed estimate: $BW MBps"
while true; do
echo -n $(date +%H:%M:%S);
Curr=$(df -m $Target |grep Seagate2T8|awk '{print $3}');
Remain=$(expr "$Total" - "$Curr")
TtRun=$(echo "(($Remain / $BW) +0.5)/1" | bc)
ETA=$(date -v+${TtRun}S)
echo ' '$Curr' +'$(expr "$Curr" - "$Last") MB "; ETA: $ETA"
Last=$Curr
sleep 100;
done
@mz0
Copy link
Author

mz0 commented Jul 5, 2018

track Google Drive sync progress (a fresh macOS downloading 62.2 GB of cloud files over 100Mbps connection)

$ toDo=62199 \
  t0=$(du -sm GDrive/ | awk '{print $1}'); \
while [ $toDo -gt $t0 ] ; do
  sleep 15
  t1=$(du -sm GDrive/ | awk '{print $1}')
  echo -n $((t1-t0)); t0=$t1; echo " $t0"
done

output:

95 34358
104 34462
96 34558
80 34638
96 34734
96 34830
96 34926
96 35022
80 35102
80 35182
96 35278
96 35374
80 35454
96 35550
96 35646
96 35742

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment