【发布时间】:2015-06-08 23:30:20
【问题描述】:
我一直在使用 ubuntu gdrive 命令行工具将我的一些文件推送到 Google Drive;但是,最近我编写了一个自动化该过程的 python 脚本: (gdrive 命令行:http://www.howopensource.com/2015/01/google-drive-for-ubuntu-linux/)
# Push to Google Drive
str_output = "\tPushing "
cmd_push = ("drive push -ignore-conflict {0}/").format(dir_db_full)
if dict_args['type'] == now:
str_output += "zip file "
cmd_push += zip_db
else:
str_output += ("\"{0}\" directory ").format(dict_args['type'])
cmd_push += dir_final + "/"
str_output += "to Google Drive..."
print str_output
cmd_push = ('export GOPATH=$HOME/go ; export PATH=$PATH:$GOPATH/bin ; yes | {0} ').format(cmd_push)
subprocess.call( cmd_push, shell=True)
这行得通!
当我通过 anacron 运行它时,整个 python 脚本运行,但似乎不正确地运行 subprocess.call;如,它不会将文件推送到 Google Drive。这是我的 anacron 文件:
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root
# These replace cron's entries
1 5 cron.daily run-parts --report /etc/cron.daily
7 10 cron.weekly run-parts --report /etc/cron.weekly
7 1 week sudo /usr/bin/python /srv/bin/backup.py -type week >> /srv/bin/log/log_backup.txt
@monthly 20 month sudo /usr/bin/python /srv/bin/backup.py -type month >> /srv/bin/log/log_backup.txt
@monthly 15 cron.monthly run-parts --report /etc/cron.monthly
没有错误报告;有人有想法吗?
【问题讨论】: