【python linux下定时任务跑】crontab -e使用

来源:互联网 发布:java nested查询 编辑:程序博客网 时间:2024/06/06 03:28

1、shell 下 执行 python程序

#!/bin/shpython /home/laidefa/msg_json/code/request_msg_json.pypython /home/laidefa/msg_json/code/ftp_uploadfile.py

2、crontab -e 下执行定时任务跑python脚本

每天八天半执行
每天八点四十执行

# 30 8 * * * usr/local/bin/python /home/laidefa/msg_json/code/request_msg_json.py  >>/home/laidefa/msg_json/log/myjob1.txt # 40 8 * * * usr/local/bin/python /home/laidefa/msg_json/code/ftp_uploadfile.py  >>/home/laidefa/msg_json/log/myjob2.txt 

3、特别注意:python的执行命令 必须用绝对路径

这里使用的是usr/local/bin/python

如何查看python执行的绝对路径?

which python
$ which python/usr/local/bin/python
原创粉丝点击