通过python脚本运行s3cmd同步&;克朗
几天来我一直在努力解决这个问题,希望能得到一些帮助-- 基本上,我编写了以下Python脚本通过python脚本运行s3cmd同步&;克朗,python,cron,ubuntu-12.04,sync,s3cmd,Python,Cron,Ubuntu 12.04,Sync,S3cmd,几天来我一直在努力解决这个问题,希望能得到一些帮助-- 基本上,我编写了以下Python脚本 import os, sys # =__=__=__=__=__=__=__ START MAIN =__=__=__=__=__=__=__ if __name__ == '__main__': # initialize variables all_files = [] # directory to download data siphon files to dDir = '/path/to/d
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)
为了回答几个问题,我以root用户身份运行cron,为root用户配置了s3cmd,操作系统是Ubuntu 12.04,python版本是2.7,所有必要的目录都有读/写权限
我错过了什么
在这里我找到了更多的s3cmd同步帮助:从cron运行任何命令最安全的方法是始终使用所有命令的完整路径:尝试将
s3cmd
替换为/usr/local/bin/s3cmd
或安装了s3cmd
的任何地方。我认为这就成功了!!!谢谢佩德罗!!
# THIS IS WHERE I AM HAVING PROBLEMS!!!!!!!!!!!
cmd = 's3cmd sync 'dDir+folderName+'/ s3://'+s3bucket+'/'
os.system(cmd)