## 概述
- 优先列出与自己模块关系紧密的任务
```
Minute Hour Day Month Week command
分钟   小时  天  月   星期  命令
0-59   0-23 1-31 1-12 0-6  command
```

## 1. /etc/cron.daily

- logrotate 做日志压缩
- 由 ssp-cron.git 的 deploy 代码做部署

## 2. /var/spool/cron/

### root
```
0 */3 * * * sync && echo 3 > /proc/sys/vm/drop_caches
#*/1 * * * * sh /data/appstore/intime/IntimeSynch-job.sh
0 6 * * * sh /data/appstore/shell/rmlog.sh
20 6 * * * sh /data/appstore/shell/rm-bmrlog.sh
*/5 * * * * cd /data/appstore/IntimeStat/ && python main.py > /data/log/IntimeStat.log 2>&1
*/5 * * * * cd /data/appstore/IntimeStat/ && python ctr-keywords.py > /data/log/ctrKeywords.log 2>&1
*/15 * * * * sh /data/appstore/shell/scan-transfer-transferbmr-defend.sh
#每隔1分钟监控一次scan transfer 并发送告警邮件
*/1 * * * * sh /data/appstore/shell/monitor_scan_transfer.sh

00 10 * * * /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w
# restart nginx on the 1st and 15st of each month.
0 0 1,15 * * sh /data/appstore/nginx/restart.sh
*/5 * * * * /opt/hosteye/bin/upgrade --upgrade_mode=8>/dev/null 2>&1
```

* 说明
- drop_caches nginx-1 为3小时一次，其他机器为6小时。清理系统缓存
- IntimeSynch-job.sh 文件找不到
- rmlog.sh  stg 中无此文件，删除过期的备份avro日志。
- rm-bmrlog.sh 删除过期的备份 xxxbmr 文件。
- IntimeStat nginx-1 才有。
  - main.py 整理 INTIME_STAT_ALL，即 实时 ctr。
  - ctr-keywords.py 整理 ssp redis 里的 ssp:ctr:keywords
  - 两个脚本，会在 /data/log/ 中留执行日志。
- scan-transfer-transferbmr-defend.sh 调起某个 jar，可能日志相关。
- monitor_scan_transfer.sh 看注释为监控上面的 transferbmr。stg 无。
- restart.sh 每月1,15两天零点，重启 nginx。nginx-1 关闭该项。

## 3. /etc/cron.d/

### appstore-thrift
`1 8 * * * root python /data/appstore/shell/appstore-thrift/clean_log.py`
- stg 无。
- 删除 appstore-thrift 太老的日志文件。
- 代码有问题，日志路径不对。

### check_folder_size
`*/10 * * * * root cd /data/appstore/nginx-watch/ && python check_folder_size.py`
- 文件和文件夹大小检查

### check_process_alive
`*/10 * * * * root cd /data/appstore/nginx-watch/ && python check_process_alive.py`
- 关键进程检查

### monitor

- 代码放入git，http://git.DT-DTG5.com/ops/ssp-cron.git

```
*/5 * * * * root cd /data/appstore/shell/monitor/ && python UserdataServiceMonitor.py > /var/log/monitor.log 2>&1
*/5 * * * * root cd /data/appstore/shell/monitor/ && python AppStoreLogMonitor.py > /var/log/monitor.log 2>&1
*/5 * * * * root cd /data/appstore/shell/monitor/ && python ProcessAliveMonitor.py > /var/log/monitor.log 2>&1
*/5 * * * * root cd /data/appstore/shell/monitor/ && python DataMonitor.py > /var/log/monitor.log 2>&1
*/5 * * * * root cd /data/appstore/shell/monitor/ && python DiskMonitor.py > /var/log/monitor.log 2>&1
#1 17 * * * root cd /data/appstore/shell/monitor/ && python ClearLogs.py > /var/log/monitor.log 2>&1
```

- UserdataServiceMonitor 访问 http://storedatasync.ad-survey.com/healthy
- AppStoreLogMonitor 监控 avro 日志
- ProcessAliveMonitor 关键进程检查，和 check_process_alive 完全重复。可去掉
- DataMonitor 监测 /data/ 文件夹大小。
- DiskMonitor 磁盘容量监测
- ClearLogs 在 nginx-1 上，功能注释了，清除一些日志文件。

### nginx-watch
`*/10 * * * * root cd /data/appstore/nginx-watch/ && python run.py`
- nginx 进程检查，和 check_process_alive 有重复，可考虑去掉。

### thrift_watch
`*/1 * * * * root /usr/local/bin/thrift_watch > /var/log/thrift_watch 2>&1`
- 调用 thrift_watch（代码位于同名 c++ 项目的 Impl 文件夹内）
- 检查共享内存里的活动更新时间，如果长时间未更新，则 level 设置为 critical
```
redis.gvsdcennvpny.scs.bj.baidubce.com:6379> hgetall warn_msg:match-center:overtime
appstore-nginx5
{"level":"normal","msg":"match-center time is 2023-08-15 18:06:07","server":"appstore-nginx5","time":"2023-08-15 18:07:01"}
appstore-nginx1
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:52","server":"appstore-nginx1","time":"2023-08-15 18:07:01"}
appstore-nginx8
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:50","server":"appstore-nginx8","time":"2023-08-15 18:07:01"}
appstore-nginx2
{"level":"normal","msg":"match-center time is 2023-08-15 18:06:07","server":"appstore-nginx2","time":"2023-08-15 18:07:01"}
appstore-nginx7
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:50","server":"appstore-nginx7","time":"2023-08-15 18:07:01"}
appstore-nginx6
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:52","server":"appstore-nginx6","time":"2023-08-15 18:07:02"}
appstore-nginx9
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:50","server":"appstore-nginx9","time":"2023-08-15 18:07:01"}
appstore-nginx12
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:50","server":"appstore-nginx12","time":"2023-08-15 18:07:01"}
appstore-nginx3
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:52","server":"appstore-nginx3","time":"2023-08-15 18:07:01"}
appstore-nginx4
{"level":"normal","msg":"match-center time is 2023-08-15 18:04:52","server":"appstore-nginx4","time":"2023-08-15 18:07:01"}
```




















