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(一周的第几天)
时序语法中的星号「*」表示每次都会运行。
修改历史10 次提交
- refactor: reorganize documentation structure and update Navbar componentxiaocheng··
2fb8f42 - chore(project): clean up obsolete configuration and build artifactsxiaocheng··
3574bd3 - new struct for lblogsxiaocheng··
8c9b28e - move blogs to docsxiaocheng··
c8535a0 - updatexiaocheng··
fd22f62 - update codechenweigao··
e4c6887 - update fix: timeline errorchenweigao··
fb4b591 - update Datechenweigao··
3c14689 - init v3chenweigao··
b770fc2 - init v2chenweigao··
505f81b