linux shell脚本实现定时压缩文件夹

实现定时自动压缩文件夹功能,因压缩需要时间,sleep时长尽量大一些

#!/bin/sh
dir=文件夹路径
fileName=生成的压缩包名字
now=$(date "+%Y%m%d_%H%M%S")  #获取当前时间,格式为年月日_时分秒,如20220719_082300
for varibale in $(seq 1 1000000)  #循环次数1000000自行修改
do
    sleep 60 #延迟时间,单位为秒
    zip -r "${fileName}_${now}" $dir # "${fileName}_${now}"表示生成的压缩包名字,如test_20220719_082300,可修改为${fileName}
done

猜你喜欢

转载自blog.csdn.net/weixin_46205984/article/details/125864145