#方法一
# 计算脚本运行时间 结束时间-开始时间=用了多少秒
# 红色部分替换成脚本
date +%s ; gzip –best -k ubuntu-22.10-server-cloudimg-amd64 ; date +%s
# 方法二
cat < test
starttime=`date +’%Y-%m-%d %H:%M:%S’`
gzip –best -k ubuntu-22.10-server-cloudimg-amd64
endtime=`date +’%Y-%m-%d %H:%M:%S’`
start_seconds=$(date –date=”$starttime” +%s);
end_seconds=$(date –date=”$endtime” +%s);
echo “本次运行时间: “$((end_seconds-start_seconds))”s”
EOF
bash ./test
补充:
xz –best
gzip –best
前者虽然省流量,但是压缩时间很久啊,十几分钟。
root@debian:~# date +%s ; gzip –best -k ubuntu-22.10-server-cloudimg-amd64 ; date +%s
1677697790
1677698098
root@debian:~# ll -h
total 3.4G
drwx—— 5 root root 4.0K Mar 2 03:09 ./
drwxr-xr-x 18 root root 4.0K Jan 24 12:35 ../
-rw——- 1 root root 1.7K Mar 2 00:59 .bash_history
-rw-r–r– 1 root root 661 Mar 1 20:42 .bashrc
drwx—— 3 root root 4.0K Mar 1 20:45 .config/
drwxr-xr-x 3 root root 4.0K Mar 1 20:43 .local/
-rw-r–r– 1 root root 161 Jul 9 2019 .profile
drwx—— 2 root root 4.0K Mar 1 20:42 .ssh/
-rw-r–r– 1 root root 192 Mar 2 03:05 test
-rw-r–r– 1 root root 3.5G Jan 1 12:00 ubuntu-22.10-server-cloudimg-amd64
-rw-r–r– 1 root root 663M Jan 1 12:00 ubuntu-22.10-server-cloudimg-amd64.gz
-rw-r–r– 1 root root 698M Mar 2 02:37 ubuntu-22.10-server-cloudimg-amd64.img
-rw-r–r– 1 root root 511M Jan 1 12:00 ubuntu-22.10-server-cloudimg-amd64.xz
root@debian:~#
湖北省网友说:time不行吗
1c512m10g 1.5T $10.18/year
1c1g25g 4T $12.98/year
2c2.5g45g 6T $24.88/year
|||WISE||挂机P2P||搬瓦吧
河北省网友说:笑死我了,还撂这教程