Crontab定时Python执行爬虫

Crontab相关参考:

https://www.runoob.com/w3cnote/linux-crontab-tasks.html

 

执行python程序:

1.先把python的执行命令写入sh脚本
2.给sh脚本添加可执行权限

chmod+xmyspidersh

3.把sh程序写入crontab配置文件中

#!/bin/sh
cd /root || exit 1
python test.py >> run.log 2>&1