Parcourir la source

feat:添加脚本

zhaohaipeng il y a 7 mois
Parent
commit
6e35cb1f51
1 fichiers modifiés avec 9 ajouts et 10 suppressions
  1. 9 10
      ad/01_ad_model_update.sh

+ 9 - 10
ad/01_ad_model_update.sh

@@ -22,29 +22,28 @@ today_early_1="$(date -d '1 days ago' +%Y%m%d)"
 train_dates=()
 
 init() {
-  local count=1
-
-  current_handle_date="$(date -d '2 days ago' +%Y%m%d)"
+  local count=0
+  local current_handle_date="$(date -d '2 days ago' +%Y%m%d)"
 
   # 循环获取前 n 天的非节日日期
-  while [[ $count -lt 8 ]]; do
+  while [[ $count -lt 7 ]]; do
     # 获取当前日期的 MM-DD 部分
-    date_key=$(date -d "$current_handle_date" +%Y%m%d)
-    echo $date_key
+    date_key=$(date -d "$current_handle_date -${count} day" +%Y%m%d)
+
+    echo "date_key: ${date_key}"
+
     # 判断是否是节日
     if [ $(is_holidays $date_key) -ge 0 ]; then
       # 如果不是节日,添加到数组中
-      train_dates+=("$date_key")
+      train_dates+=($date_key)
       # 计数器加 1
       count=$((count + 1))
     fi
 
     # 日期递减 1 天
-    current_handle_date=$(date -d "$current_handle_date -1 day" +%Y%m%d)
+    # current_handle_date=$(date -d "$current_handle_date -$ day" +%Y%m%d)
   done
 
-  echo ${train_dates}
-
 }