Files
hzdyjs/退学、休学、复学、毕业/optional_crontab_config.txt
T
2025-12-25 18:01:27 +08:00

70 lines
2.6 KiB
Plaintext

# ===========================================
# 学生状态变更处理脚本 - 可选的Crontab配置
# ===========================================
# 注意:脚本现在采用持续运行模式,默认每10分钟自动处理一次
# 此配置文件仅供特殊情况下的备用配置使用
# 如果不使用持续运行模式,可以使用以下crontab配置:
# 1. 将以下内容添加到系统的 crontab 中:crontab -e
# 2. 根据实际需要调整执行时间和频率
# 3. 确保脚本路径正确
# 4. 确保用户有执行权限
# 脚本所在目录(请根据实际情况修改)
SCRIPT_DIR="/path/to/student_status_scripts"
# 每天早上8点执行学生状态变更处理
0 8 * * * $SCRIPT_DIR/process_student_changes.sh
# 每天早上8点30分执行学生复学处理
30 8 * * * $SCRIPT_DIR/process_student_resume.sh
# 每小时执行一次健康检查
0 * * * * $SCRIPT_DIR/health_check.sh report
# 每周一早上6点重启所有服务(可选,用于定期重启确保稳定性)
0 6 * * 1 $SCRIPT_DIR/stop_services.sh && sleep 5 && $SCRIPT_DIR/start_services.sh
# 每天晚上10点清理旧日志文件(保留7天)
0 22 * * * find $SCRIPT_DIR/logs -name "*.log" -type f -mtime +7 -delete
# 每分钟检查服务状态,如果服务停止则自动重启(可选)
# */1 * * * * $SCRIPT_DIR/control_scripts.sh statusall >/dev/null 2>&1 || ($SCRIPT_DIR/stop_services.sh force && $SCRIPT_DIR/start_services.sh)
# ===========================================
# Crontab 语法说明
# ===========================================
# 分 时 日 月 周 命令
# * * * * * command
#
# 字段说明:
# 分 - 0-59
# 时 - 0-23
# 日 - 1-31
# 月 - 1-12
# 周 - 0-7 (0和7都表示星期日)
#
# 常用示例:
# 0 8 * * * - 每天早上8点
# */30 * * * * - 每30分钟
# 0 */2 * * * - 每2小时
# 0 9-17 * * 1-5 - 周一到周五的9点到17点,每小时执行一次
# @reboot - 系统重启时执行
# ===========================================
# 监控和告警建议
# ===========================================
# 1. 监控日志中的ERROR关键字
# 可以使用logwatch或自定义脚本监控日志
# 2. 监控数据库连接
# */5 * * * * mysql -h host -u user -p pass -e "SELECT 1;" || echo "DB connection failed" | mail -s "DB Alert" admin@example.com
# 3. 监控磁盘空间
# */30 * * * * df /var/log | awk 'NR==2 {if($5>90) print "Disk usage high: "$5}' | mail -s "Disk Alert" admin@example.com
# 4. 监控进程状态
# */5 * * * * pgrep -f "process_student_changes.sh" >/dev/null || echo "Process died" | mail -s "Process Alert" admin@example.com