API-vendor/container/datax/scripts/sync_orders.sh

19 lines
1013 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 设置工作目录
cd /Users/zksu/Developer/work/workcode/API-vendor/container
# 记录开始时间
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 开始执行订单同步..." > /tmp/orders_sync_start.log
# 执行 DataX 作业
docker-compose exec -T datax python /datax/bin/datax.py /datax/job/restful_to_mysql_orders.json > /Users/zksu/Developer/work/workcode/API-vendor/container/datax/log/orders_sync_$(date +%Y%m%d_%H%M%S).log 2>&1
# 检查执行结果
if [ $? -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 订单同步执行成功" >> /tmp/orders_sync_start.log
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] 订单同步执行失败" >> /tmp/orders_sync_start.log
# 发送告警通知示例企业微信机器人如需使用请取消注释并修改webhook地址
# curl -s -H "Content-Type: application/json" -d '{"msgtype": "text", "text": {"content": "订单同步执行失败,请查看日志"}}' https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=your_webhook_key
fi