ubuntu crontab python 定时任务备记

crontab -e 写入:

# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
50 09 * * * notify-send 'take a break now!' 
*/30 * * * * export DISPLAY=:0.0; /bin/bash /home/jkmiao/workspace/shell/take_break.sh  */1 * * * * /bin/bash /home/jkmiao/workspace/test/crontab_test.sh */1 * * * * /home/jkmiao/workspace/test/crontab_test.py

注意:

# 如果已经在test.py首行加入了#!/usr/local/bin/env python,那么在crontab定时任务定义只需要:

30 12 * * * /x/test.py

# 否则需要指定绝对路径
30 12 * * * /usr/local/bin/python2.7 /x/test.py

# 同时注意, 程序中的文件路径也必须为绝对路径,否则pemission denied 错误

 查看结果邮件: cat /var/mail/jkmiao

 

posted on 2017-07-05 10:54  星空守望者--jkmiao  阅读(560)  评论(2编辑  收藏  举报