研究过比较多的cronjob,根据项目需要最后选了在 docker 里面运行cronjob 进行管理。 建议大家可以根据需要选择对应的cronjob
XXLjob
https://github.com/xuxueli/xxl-job
cronsun
https://github.com/shunfei/cronsun
airflow
https://github.com/apache/airflow
docker cronjob
如果要实时刷新crontabs,需要在 /etc/crontabs/root
同级目录刷一个随机文件进去,docker 就自动更新root 的cronjob了
docker file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
FROM alpine
#RUN apk update && apk add curl nano --update python2==2.7.18-r0
RUN apk update && apk add curl nano --update python3==3.8.5-r0 py-pip
# for python3: --update python3 py-pip
COPY requirements /requirements
COPY get-pip.py /tmp/
#RUN python /tmp/get-pip.py
RUN pip install -r /requirements
ENV KEYONE=KEYVALUEFROM
COPY prod/yourprojectname/ /etc/crontabs/root
COPY prod /opt/yourprojectname
# start crond with log level 8 in foreground, output to stderr
CMD ["crond", "-f", "-d", "8","-c","/etc/crontabs"]
|