Bash 脚本手动运行,但在 crontab 中失败
Bash script runs manually, but fails in crontab
我在 /amadeus 文件夹中有这个脚本 ftp.sh:
#!/bin/bash
. /home/thierry/.bash_profile
# constantes
HOST=xxxx
LOGIN=xxxxx
PASSWORD=xxxxxx
PORT=21
ftp -i -n $HOST $PORT << END_SCRIPT
quote USER $LOGIN
quote PASS $PASSWORD
cd www
pwd
asc
mput *.json
quit
END_SCRIPT
对于同一用户,此命令工作正常:
$ . /amadeus/ftp.sh
=> 一个 json 文件被很好地放置到远程服务器。
但是在 crontab 中有这个条目:
* * * * * . /amadeus/ftp.sh 2>/tmp/2.log 1>/tmp/1.log
我每秒创建文件 1.log 和 2.log,但 none json 文件在远程服务器中。
tmp]$ ll
-rw-r--r-- 1 thierry thierry 36 Jan 27 16:00 1.log
-rw-r--r-- 1 thierry thierry 0 Jan 27 16:00 2.log
tmp]$ more 1.log
257 "/www" is your current location
tmp]$ more 2.log
tmp]$
非常感谢您的回答!
西奥.
在 ftp 命令之前,我必须“cd”到正确的文件夹 /amadeus,现在它工作正常!
我在 /amadeus 文件夹中有这个脚本 ftp.sh:
#!/bin/bash
. /home/thierry/.bash_profile
# constantes
HOST=xxxx
LOGIN=xxxxx
PASSWORD=xxxxxx
PORT=21
ftp -i -n $HOST $PORT << END_SCRIPT
quote USER $LOGIN
quote PASS $PASSWORD
cd www
pwd
asc
mput *.json
quit
END_SCRIPT
对于同一用户,此命令工作正常:
$ . /amadeus/ftp.sh
=> 一个 json 文件被很好地放置到远程服务器。
但是在 crontab 中有这个条目:
* * * * * . /amadeus/ftp.sh 2>/tmp/2.log 1>/tmp/1.log
我每秒创建文件 1.log 和 2.log,但 none json 文件在远程服务器中。
tmp]$ ll
-rw-r--r-- 1 thierry thierry 36 Jan 27 16:00 1.log
-rw-r--r-- 1 thierry thierry 0 Jan 27 16:00 2.log
tmp]$ more 1.log
257 "/www" is your current location
tmp]$ more 2.log
tmp]$
非常感谢您的回答! 西奥.
在 ftp 命令之前,我必须“cd”到正确的文件夹 /amadeus,现在它工作正常!