在脚本中运行它时出现“错误s3cmd:command not found”,尽管安装它并且&设置环境变量。也可以从命令提示符运行s3cmd!
记录:
# tail -f /mnt/log/frengo/s3_sync_ox_data_raw_ad_external_2.log
SECONDS:0 MICRO_SECONDS:299000
SECONDS:0 MICRO_SECONDS:45000
INDEX:2 CURRENTHOUR:11 CURRENTMINUTE:19 CURRENTMINUTEINTERVAL:1
START S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.037471786
/root/adserver_cron/./s3_sync_index.sh: line 92: s3cmd: command not found
END S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.038967376
INDEX:2 CURRENTHOUR:11 CURRENTMINUTE:13 CURRENTMINUTEINTERVAL:0
START S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.292091013
/root/adserver_cron/./s3_sync_prev_index.sh: line 92: s3cmd: command not found
END S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.293705403
s3cmd:
# /usr/local/bin/s3cmd --version
s3cmd version 1.0.1
# s3cmd --version
s3cmd version 1.0.1
两者都相同!!
脚本:
RESPONSE=$(s3cmd sync s3://dm-raw-files/${INDEX}/${CURRENTDATE}/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ /mnt2/frengo/fileQueue/${INDEX}/s3/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ 2>&1 )
s3cmd正在命令提示符下运行:
# s3cmd ls s3://dm-raw-files
DIR s3://dm-raw-files//
DIR s3://dm-raw-files/0/
DIR s3://dm-raw-files/1/
还设置了env变量:
# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -d "$HOME/s3" ]; then
PATH="$HOME/s3:$PATH"
fi
答案 0 :(得分:2)
更改脚本以包含s3cmd的完整路径:
RESPONSE=$(/usr/local/bin/s3cmd sync s3://dm-raw-files/......
答案 1 :(得分:1)
检查是否从根目录访问了s3cmd。
将用户更改为root
sudo su
尝试运行命令
s3cmd
如果找不到命令,请执行
sudo apt-get s3cmd
这将以root用户身份安装s3cmd,现在尝试运行cron。