prodassist / scripts /setup_cron.sh
Chetan Anand
Deploy ProdAssist RAG β€” 5-company support chatbot
b7d2428
Raw
History Blame Contribute Delete
2.82 kB
#!/usr/bin/env bash
# =============================================================================
# setup_cron.sh β€” Register a weekly cron job that automatically:
# 1. Re-fetches documentation from all 5 company help centers
# 2. Ingests the fresh content into the ChromaDB vector store
#
# Usage:
# chmod +x scripts/setup_cron.sh
# ./scripts/setup_cron.sh
#
# To remove the cron job later:
# crontab -l | grep -v "fetch_company_docs" | crontab -
# =============================================================================
set -euo pipefail
# ── Resolve absolute paths ────────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_DIR="$(dirname "$SCRIPT_DIR")"
PYTHON="$APP_DIR/.venv/bin/python"
LOG_FILE="$APP_DIR/logs/cron_ingest.log"
if [ ! -f "$PYTHON" ]; then
echo "ERROR: Python not found at $PYTHON"
echo "Make sure the virtual environment is set up: cd $APP_DIR && python -m venv .venv && pip install -r requirements.txt"
exit 1
fi
mkdir -p "$APP_DIR/logs"
# ── Build the cron command ────────────────────────────────────────────────────
# Runs every Sunday at 02:00 AM
CRON_SCHEDULE="0 2 * * 0"
INGEST_CMD="cd \"$APP_DIR\" && \
\"$PYTHON\" scripts/fetch_company_docs.py >> \"$LOG_FILE\" 2>&1 && \
\"$PYTHON\" main.py ingest \
data/notion/notion_support_docs.txt \
data/slack/slack_support_docs.txt \
data/github/github_support_docs.txt \
data/zoom/zoom_support_docs.txt \
data/shopify/shopify_support_docs.txt \
>> \"$LOG_FILE\" 2>&1"
CRON_LINE="$CRON_SCHEDULE $INGEST_CMD"
# ── Install (idempotent) ──────────────────────────────────────────────────────
echo "Installing weekly cron job…"
echo "Schedule : $CRON_SCHEDULE (every Sunday at 02:00)"
echo "App dir : $APP_DIR"
echo "Log file : $LOG_FILE"
echo ""
# Remove any existing entry for this script, then add the new one
( crontab -l 2>/dev/null | grep -v "fetch_company_docs"; echo "$CRON_LINE" ) | crontab -
echo "βœ“ Cron job installed successfully."
echo ""
echo "Verify with: crontab -l"
echo ""
echo "To run manually right now:"
echo " cd \"$APP_DIR\" && \\"
echo " \"$PYTHON\" scripts/fetch_company_docs.py && \\"
echo " \"$PYTHON\" main.py ingest \\"
echo " data/notion/notion_support_docs.txt \\"
echo " data/slack/slack_support_docs.txt \\"
echo " data/github/github_support_docs.txt \\"
echo " data/zoom/zoom_support_docs.txt \\"
echo " data/shopify/shopify_support_docs.txt"