source /etc/profile
echo $ROV_OFFLINE_ENV

log_dir="my_logs_alg_recsys_feature_03_vidhasreturnrov1d7d_redis"
if [ ! -d ${log_dir} ]; then
    mkdir ${log_dir}
fi

cur_time="`date +%Y%m%d`"
cur_h="`date +%H`"
echo "开始执行时间:{$(date "+%Y-%m-%d %H:%M:%S")}"
if [[ $ROV_OFFLINE_ENV == 'test' ]]; then
  /root/anaconda3/bin/python alg_recsys_feature_03_vidhasreturnrov1d7d_redis.py $cur_time $cur_h
elif [[ $ROV_OFFLINE_ENV == 'pro' ]]; then
  /root/anaconda3/bin/python alg_recsys_feature_03_vidhasreturnrov1d7d_redis.py $cur_time $cur_h
  if [ $? -ne 0 ]; then
    msg="写redis的任务，视频特征排序使用，有回流的曝光的rovn,1d~7d，alg_recsys_feature_03_vidhasreturnrov1d7d_redis.py:${cur_time}-${cur_h}-something-is-wrong."
    /root/anaconda3/bin/python utils_monitor.py ${msg}
  fi
fi
echo "结束执行时间:{$(date "+%Y-%m-%d %H:%M:%S")}"
echo "all done"

day="$(date -d '10 days ago' +%Y-%m-%d)"
base_path=${log_dir}
pattern="${base_path}/${day}*"
if compgen -G "$pattern" > /dev/null; then
    echo "找到匹配的文件，正在删除..."
    # 使用find命令查找并删除匹配的文件
    find "$base_path" -name "${day}*" -exec rm -rf {} \;
    echo "文件已被删除。"
else
    echo "没有找到匹配的文件，无需删除。"
fi


# sh alg_recsys_feature_03_vidhasreturnrov1d7d_redis_task.sh