diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 5099eff..4556257 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -1,7 +1,7 @@ name: Run Report Table on: schedule: - - cron: '0 21 * * *' # 06:00 KST is 21:00 UTC + - cron: "0 21 * * *" # 06:00 KST is 21:00 UTC jobs: run-script: runs-on: ubuntu-latest @@ -9,4 +9,9 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Run script - run: ./run_table.sh + run: | + if [ $(date -u +%u) -eq 1 ]; then + ./run_table.sh 7d + else + ./run_table.sh 24h + fi diff --git a/run_table.sh b/run_table.sh index 6960510..189ec33 100644 --- a/run_table.sh +++ b/run_table.sh @@ -7,7 +7,7 @@ set +a LOG_DIR="logs/table" mkdir -p "${LOG_DIR}" -ABSOLUTE_RANGE=7d # 24h +ABSOLUTE_RANGE=${1:-24h} TS="$(date +%Y%m%d_%H%M%S)" LOG_FILE="${LOG_DIR}/report_${ABSOLUTE_RANGE}_${TS}.log" @@ -17,10 +17,4 @@ LOG_FILE="${LOG_DIR}/report_${ABSOLUTE_RANGE}_${TS}.log" >> "${LOG_FILE}" 2>&1 & echo "[OK] Started background job." -echo "[OK] Logging to ${LOG_FILE}" - -# # crontab -e -# # 매일 09:00 KST에 지난 24시간 보고 -# 0 9 * * * /usr/bin/env bash -lc 'cd /opt/monitor && /usr/bin/python3 grafana_dash_pull_and_alert.py --range 24h' -# # 매주 월요일 09:30 KST에 지난 7일 보고 -# 30 9 * * 1 /usr/bin/env bash -lc 'cd /opt/monitor && /usr/bin/python3 grafana_dash_pull_and_alert.py --range 7d' \ No newline at end of file +echo "[OK] Logging to ${LOG_FILE}" \ No newline at end of file