| 
														
															@@ -187,6 +187,24 @@ else 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     exit 1 
														 | 
														
														 | 
														
															     exit 1 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 fi 
														 | 
														
														 | 
														
															 fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 5.6 使用前一天线上模型和前一天的新模型对前一天的数据进行预测并计算AUC 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+yesterday_online_model=${LAST_MODEL_HOME}/model_online.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 5.6.1 判断model_online文件的生成时间,如果是昨天生成的则表示模型有更新 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# ${MODEL_PATH}/${model_name}_${today_early_1}.txt 和 ${LAST_MODEL_HOME}/model_online_$(date +\%Y\%m\%d).txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+file_creation_date=$(stat -c %W "$yesterday_online_model") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+file_creation_date_format=$(date -d "@$file_creation_date" +%Y%m%d) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+if [ "$file_creation_date_format" == "$today_early_1" ]; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  yesterday_online_model=${LAST_MODEL_HOME}/model_online_${today_early_1}.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 5.6.2 使用昨天的线上模型,进行预测 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+$HADOOP fs -text ${bucketFeatureSavePath}/${today_early_1}/* | ${FM_HOME}/bin/fm_predict -m "$yesterday_online_model" -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today_early_1}_online_all.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+yesterday_online_auc=`cat ${PREDICT_PATH}/${model_name}_${today_early_1}_online_all.txt | /root/sunmingze/AUC/AUC` 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 5.6.3 使用昨天的新模型,进行预测 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+$HADOOP fs -text ${bucketFeatureSavePath}/${today_early_1}/* | ${FM_HOME}/bin/fm_predict -m ${MODEL_PATH}/${model_name}_${today_early_2}.txt -dim 8 -core 8 -out ${PREDICT_PATH}/${model_name}_${today_early_1}_new_all.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+yeaterday_new_auc=`cat ${PREDICT_PATH}/${model_name}_${today_early_1}_new_all.txt | /root/sunmingze/AUC/AUC` 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # 6 模型格式转换 
														 | 
														
														 | 
														
															 # 6 模型格式转换 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -247,7 +265,9 @@ echo -e "$LOG_PREFIX -- 模型文件推送至OSS -- 广告模型文件至OSS成 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # 8 本地保存最新的线上使用的模型,用于下一次的AUC验证 
														 | 
														
														 | 
														
															 # 8 本地保存最新的线上使用的模型,用于下一次的AUC验证 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 step_start_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
														
														 | 
														
															 step_start_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-cp -f ${LAST_MODEL_HOME}/model_online.txt ${LAST_MODEL_HOME}/model_online_$(date +\%Y\%m\%d).txt 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 将之前的线上模型进行备份,表示从上一个备份时间到当前时间内,使用的线上模型都是此文件 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# 假设当前是07-11,上一次备份时间为07-07。备份之后表示从07-07下午至07-11上午线上使用的模型文件都是model_online_20240711.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+cp -f ${LAST_MODEL_HOME}/model_online.txt ${LAST_MODEL_HOME}/model_online_${today}.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 cp -f ${MODEL_PATH}/${model_name}_${today_early_1}.txt ${LAST_MODEL_HOME}/model_online.txt 
														 | 
														
														 | 
														
															 cp -f ${MODEL_PATH}/${model_name}_${today_early_1}.txt ${LAST_MODEL_HOME}/model_online.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 step_end_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
														
														 | 
														
															 step_end_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -264,11 +284,10 @@ echo -e "$LOG_PREFIX -- 模型备份 -- 模型备份完成: 耗时 $step_elapsed 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # 9 任务完成通知 
														 | 
														
														 | 
														
															 # 9 任务完成通知 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 step_end_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
														
														 | 
														
															 step_end_time=$(date "+%Y-%m-%d %H:%M:%S") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-msg="\n\t - 广告模型文件更新完成 \n\t - 新模型AUC: $new_auc \n\t - 线上模型AUC: $online_auc  \n\t - AUC差值: $auc_diff_abs \n\t - 模型上传路径: $online_model_path" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+msg="\n\t - 广告模型文件更新完成 \n\t - 前一天线上模型全天数据AUC: $yesterday_online_auc} \n\t - 前一天新模型全天数据AUC: $yeaterday_new_auc \n\t - 新模型AUC: $new_auc \n\t - 线上模型AUC: $online_auc  \n\t - AUC差值: $auc_diff_abs \n\t - 模型上传路径: $online_model_path" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 echo -e "$LOG_PREFIX -- 模型更新完成 -- $msg: 耗时 $step_elapsed" 
														 | 
														
														 | 
														
															 echo -e "$LOG_PREFIX -- 模型更新完成 -- $msg: 耗时 $step_elapsed" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 elapsed=$(($(date +%s -d "$step_end_time") - $(date +%s -d "$start_time"))) 
														 | 
														
														 | 
														
															 elapsed=$(($(date +%s -d "$step_end_time") - $(date +%s -d "$start_time"))) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 /root/anaconda3/bin/python ad/ad_monitor_util.py --level info --msg "$msg" --start "$start_time" --elapsed "$elapsed" 
														 | 
														
														 | 
														
															 /root/anaconda3/bin/python ad/ad_monitor_util.py --level info --msg "$msg" --start "$start_time" --elapsed "$elapsed" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # 15 15 * * * cd /root/zhaohp/recommend-emr-dataprocess && /bin/sh ./ad/01_ad_model_update_everyday.sh > logs/01_update_eventday_$(date +\%Y-\%m-\%d_\%H-\%M).log 2>&1 
														 | 
														
														 | 
														
															 # 15 15 * * * cd /root/zhaohp/recommend-emr-dataprocess && /bin/sh ./ad/01_ad_model_update_everyday.sh > logs/01_update_eventday_$(date +\%Y-\%m-\%d_\%H-\%M).log 2>&1 
														 |