我这几天一直在尝试解决这个问题,希望能得到一些帮助——
基本上,我编写了以下 Python 脚本
import os, sys
# =__=__=__=__=__=__=__ START MAIN =__=__=__=__=__=__=__
if __name__ == '__main__':
# initialize variables
all_files = []
# directory to download data siphon files to
dDir = '/path/to/download/directory/'
# my S3 bucket
s3bucket = "com.mybucket/"
foldername = "test"
# get a list of available feeds
feeds = <huge JSON object with URLs to feeds>
for item in range(feeds['count']):
# ...check if the directory exists, and if not, create the directory...
if not os.path.exists(folderName):
os.makedirs(folderName)
... ... ...
# Loop through all the splits
for s in dsSplits:
... ... ...
location = requestFeedLocation(name, timestamp)
... ... ...
downloadFeed(location[0], folderName, nameNotGZ)
# THIS IS WHERE I AM HAVING PROBLEMS!!!!!!!!!!!
cmd = 's3cmd sync 'dDir+folderName+'/ s3://'+s3bucket+'/'
os.system(cmd)
我的代码中的所有内容都有效...当我直接从命令行运行时,一切都按预期运行...但是,当我通过 cron 执行它时——以下内容不执行(其他所有内容都执行)
# THIS IS WHERE I AM HAVING PROBLEMS!!!!!!!!!!!
cmd = 's3cmd sync 'dDir+folderName+'/ s3://'+s3bucket+'/'
os.system(cmd)
为了回答几个问题,我以 root 身份运行 cron,为 root 用户配置了 s3cmd,操作系统是 Ubuntu 12.04,python 版本是 2.7,所有必要的目录都具有读/写权限...
我错过了什么?