trading.ai/start_market_scanner.sh
2025-11-02 10:41:17 +08:00

52 lines
1.3 KiB
Bash
Executable File
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
# 市场扫描服务启动脚本
echo "🚀 启动市场扫描定时任务服务..."
# 创建日志目录
mkdir -p /app/logs
# 安装cron
echo "📦 安装cron服务..."
apt-get update && apt-get install -y cron
# 复制crontab配置
echo "⏰ 配置定时任务..."
cp /app/crontab/market-scanner /etc/cron.d/market-scanner
# 设置权限必须是0644且属于root
chmod 0644 /etc/cron.d/market-scanner
chown root:root /etc/cron.d/market-scanner
# 确保文件以换行符结尾
echo "" >> /etc/cron.d/market-scanner
# 启动cron服务
echo "🔄 启动cron守护进程..."
service cron start
# 检查cron服务状态
service cron status
# 显示已配置的任务
echo "📋 已配置的定时任务:"
cat /etc/cron.d/market-scanner
# 测试cron日志权限
touch /app/logs/cron.log
chmod 666 /app/logs/cron.log
# 记录启动信息
echo "$(date): 市场扫描服务启动完成" >> /app/logs/scanner_startup.log
echo "✅ 市场扫描定时任务服务启动完成"
echo "📝 日志文件: /app/logs/market_scanner.log"
echo "⏰ Cron日志: /app/logs/cron.log"
# 执行一次初始扫描
echo "🔍 执行初始市场扫描..."
python /app/market_scanner.py
# 保持容器运行并显示日志
echo "👁️ 监控日志输出..."
tail -f /app/logs/market_scanner.log /app/logs/cron.log