Files
nanocode/it_automation_enhanced/scripts/setup_cron.sh
T
Ubuntu 32b43f85bd a
2026-07-03 16:58:28 +08:00

41 lines
1.4 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
# 设置IT资讯自动化系统的cron定时任务
echo "============================================================"
echo "🕐 配置IT资讯自动化系统定时任务"
echo "============================================================"
CRON_JOB="0 16 * * * /bin/bash /home/ubuntu/nanocode/it_automation_enhanced/scripts/main_scheduler.sh"
CRON_COMMENT="# IT资讯自动化系统 - 每天16:00执行"
echo "定时任务配置:"
echo " $CRON_JOB"
echo ""
echo "执行内容:"
echo " • 网页抓取(InfoQ, Wired, TechCrunch)"
echo " • 文章处理(翻译、去AI化、格式转换)"
echo " • 小红书发布(自动发布技术资讯)"
echo " • 日志记录和清理"
echo ""
# 检查是否已存在该任务
if crontab -l 2>/dev/null | grep -q "main_scheduler.sh"; then
echo "⚠️ 定时任务已存在,将更新"
# 删除现有任务
crontab -l 2>/dev/null | grep -v "main_scheduler.sh" | crontab -
fi
# 添加新任务
(crontab -l 2>/dev/null; echo ""; echo "$CRON_COMMENT"; echo "$CRON_JOB") | crontab -
echo "✅ 定时任务配置完成"
echo ""
echo "📋 当前cron任务列表:"
crontab -l 2>/dev/null | grep -A2 -B2 "IT资讯"
echo ""
echo "💡 管理命令:"
echo " • 查看所有任务: crontab -l"
echo " • 编辑任务: crontab -e"
echo " • 删除所有任务: crontab -r"
echo " • 手动测试: /bin/bash /home/ubuntu/nanocode/it_automation_enhanced/scripts/main_scheduler.sh"