我的问题是,cronjob似乎运行良好,但没有在.sh文件中正确执行代码,请参阅下面的详细信息。Cronjob - 运行脚本和Python
我键入crontab -e命令,弹出的cron: 在该文件中:
30 08 * * 1-5 /home/user/path/backup.sh
45 08 * * 1-5 /home/user/path/runscript.sh >> /home/user/cronlog.log 2>&1
backup.sh:
#!/bin/sh
if [ -e "NEW_BACKUP.sql.gz" ]
then
mv "NEW_BACKUP.sql.gz" "OLD_BACKUP.sql.gz"
fi
mysqldump -u username -ppassword db --max_allowed_packet=99M | gzip -9c > NEW_BACKUP.sql.gz
runscript.sh:
#!/bin/sh
python /home/user/path/uber_sync.py
uber_sync .py:
import keyword_sync
import target_milestone_sync
print "Starting Sync"
keyword_sync.sync()
print "Keyword Synced"
target_milestone_sync.sync()
print "Milestone Synced"
print "Finished Sync"
问题是,它似乎在uber_sync中执行打印语句,但实际上并没有从导入语句执行代码......任何想法?
还要注意的是keyword_sync和target_milestone_sync位于作为uber_sync,即/ home/user中/路径
感谢您的帮助同一目录中。
那么,结局在'/ home/user/cronlog.log'中?任何堆栈跟踪? - 哦,并且不知道'sync()'是做什么的,这很难说出什么地方会出错。 – mata
检查PATH。 – Daenyth