Crontab
使用 crontab 和 python-crontab 做定时任务
使用 crontab 做定时任务或循环任务。
pip install python-crontab
时序语法
现在,要安排一个 cron 作业来执行上面的脚本来输出到另一个文件,你需要添加以下代码行:
50 19 * * * python hello.py >> a.txt
上述代码行将文件的标准输出重定向到名为 a.txt 的文件中。要执行命令前面的数字定义了作业的执行时间。时序语法有五个部分:
- minute(分钟)
- hour(小时)
- day of month(月的第几天)
- month(月)
- day of week(一周的第几天)
时序语法中的星号「*」表示每次都会运行。
修改历史12 次提交
- fix(wiki): clean all lint errors to enable strict CI (PR-3)xiaocheng··
9acd1f2 - refactor: reorganize documentation structure and update Navbar componentxiaocheng··
e7d22e5 - chore(project): clean up obsolete configuration and build artifactsxiaocheng··
d659171 - new struct for lblogsxiaocheng··
6ea1ca2 - move blogs to docsxiaocheng··
a8edecd - updatexiaocheng··
fafb44b - update codechenweigao··
e069c6c - update fix: timeline errorchenweigao··
90c74ab - update Datechenweigao··
35bdb9c - init v3chenweigao··
065a35c - init v2chenweigao··
505f81b