crontab 中不能执行定时任务的问题

*/1 * * * * cd /data/application/cmdb_test/script && python sync_user.py > /home/deploy/cmdb.log    # 每分钟执行一次,sync_user.py   

问题是:cd /data/application/cmdb_test/script && python sync_user.py 在命令行是可以执行成功的,放到 crontab 中就不能正常执行

原因是:python 没有写绝对路径,找绝对路径的方法 which python

 

crontab 语法:  每十二小时执行一次(0 */12 * * * do some things)

 

 

posted @ 2018-02-08 17:01  in_the_way  阅读(153)  评论(0编辑  收藏  举报