删除过时的hls缓存

来源:互联网 发布:淘宝宝贝描述尺寸 编辑:程序博客网 时间:2024/06/03 21:10
#!/bin/bash
debug=0
for dir in `find /usr/local/nginx/html/ -type d`
do
test $debug -gt 1 && echo $dir
string=`echo $dir | awk -F "/" '{print $NF}'`
if [ "$string"x == "high"x ];then
test $debug -gt 0 && echo $string
continue
elif [ "$string"x == "low"x ];then
test $debug -gt 0 && echo $string
continue
elif [ "$string"x == "x" ];then
continue
else
for ts_list in `find $dir -name '*.ts' -type f`
do
ts_time=`stat -c %y $ts_list|awk -F "." '{print $1}'`
m3u8_time=`stat -c %y $dir"/test.m3u8"|awk -F "." '{print $1}'`
time_diff=$(($(date +%s -d "$m3u8_time") - $(date +%s -d "$ts_time")))
test $debug -gt 0 && echo $time_diff
if [ $time_diff -gt 180 ];then
test $debug -gt 0 && echo $dir
test $debug -gt 0 && echo $ts_list
rm -f $ts_list
fi
done
fi
done
原创粉丝点击