Crontab 定时执行程序(爬虫)

Crontab定时执行



设置一个可执行脚本: test.sh #名字随便起

#!/bin/sh
cd `dirname $0` || exit 1
/usr/bin/python3.5 hello.py >> run.log 2>&1 # 执行命令 执行文件 程序错误日志

在crontab 中设置执行脚本的时间、路径:

# 编辑脚本: crontab -e

* * * * * /home/zdw/test.sh >> /home/zdw/run1.log 2>&1 #执行时间 执行脚本 脚本错误日志

查看crontab内容: crontab -l


其他:
查看Python程序路径: whereis python
查看动态log日志: tail -f run.log





发布了9 篇原创文章 · 获赞 18 · 访问量 6573

猜你喜欢

转载自blog.csdn.net/zlc1990628/article/details/80878837