我在 /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 文件,但远程服务器中没有 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]$
非常感谢您的回答! 提奥。
答案 0 :(得分:0)
在执行 ftp 命令之前,我必须对正确的文件夹 /amadeus 执行“cd”操作,现在它可以正常工作了!