I have this script ftp.sh in /amadeus folder:
#!/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
With the same user this command works fine:
$ . /amadeus/ftp.sh
=> a json file is well putted to the remote server.
But with this entry in crontab:
* * * * * . /amadeus/ftp.sh 2>/tmp/2.log 1>/tmp/1.log
I have files 1.log and 2.log created every second but none json file in remote server.
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]$
Thanks a lot for yours answers!
Théo.
question from:
https://stackoverflow.com/questions/65921862/bash-script-runs-manually-but-fails-in-crontab 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…