从脚本中获取 "error s3cmd: command not found" 而 运行
Getting "error s3cmd: command not found" while running it from script
获取 "error 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/
也设置了环境变量:
# 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
更改脚本以包含 s3cmd 的完整路径:
RESPONSE=$(/usr/local/bin/s3cmd sync s3://dm-raw-files/......
检查是否从根目录访问了 s3cmd。
将用户更改为 root
sudo su
尝试 运行 命令
s3cmd
如果你得到命令未找到然后做
sudo apt-get install s3cmd
这将以 root 身份安装 s3cmd 现在尝试 运行 cron。
获取 "error 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/
也设置了环境变量:
# 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
更改脚本以包含 s3cmd 的完整路径:
RESPONSE=$(/usr/local/bin/s3cmd sync s3://dm-raw-files/......
检查是否从根目录访问了 s3cmd。
将用户更改为 root
sudo su
尝试 运行 命令
s3cmd
如果你得到命令未找到然后做
sudo apt-get install s3cmd
这将以 root 身份安装 s3cmd 现在尝试 运行 cron。