简体   繁体   English

从脚本运行时出现“错误 s3cmd:找不到命令”

[英]Getting "error s3cmd: command not found" while running it from script

Getting "error s3cmd: command not found" while running it from script in spite of installing it & setting environment variable.尽管安装了它并设置了环境变量,但在从脚本运行它时出现“错误 s3cmd:找不到命令”。 Also able to run s3cmd from command prompt !还可以从命令提示符运行 s3cmd !

Log :日志 :

# 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 : s3cmd :

# /usr/local/bin/s3cmd --version
s3cmd version 1.0.1
# s3cmd --version
s3cmd version 1.0.1

both are same !!两个都一样!!

Script :脚本 :

 RESPONSE=$(s3cmd sync s3://dm-raw-files/${INDEX}/${CURRENTDATE}/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ /mnt2/frengo/fileQueue/${INDEX}/s3/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ 2>&1 )

s3cmd is working from command prompt : s3cmd 在命令提示符下工作:

# s3cmd ls s3://dm-raw-files
                       DIR   s3://dm-raw-files//
                       DIR   s3://dm-raw-files/0/
                       DIR   s3://dm-raw-files/1/

Has set env variable also :还设置了 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

更改脚本以包含 s3cmd 的完整路径:

RESPONSE=$(/usr/local/bin/s3cmd sync s3://dm-raw-files/......

Check if s3cmd is accessed from the root.检查是否从根访问 s3cmd。

Change the user to root将用户更改为root

sudo su

Try running command尝试运行命令

s3cmd

If you get command not found then do如果找不到命令,请执行以下操作

sudo apt-get s3cmd

This will install the s3cmd as root now try running cron.这将以 root 身份安装 s3cmd 现在尝试运行 cron。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM