In order to troubleshoot some ftp connection error, I've been instructed to write a bash script which will infinitely connect to a remote frp server and get one file from there.
ftpuser="ftpuser"
ftppasswd="ftppasswd"
ftpsrv="download.akamai.com"
log="/var/log/test_ftp_akamai.log"
function print_log {
echo $(date +'%d-%m-%y %H:%M:%S') $* >> $log
}
while true
do print_log "-----===== Start =====------" | tee -a $log
/usr/bin/wget ftp://$ftpuser:$ftppasswd@$ftpsrv | tee -a $log
sleep 2 | tee -a $log
print_log "-----===== Done =====------" | tee -a $log
done
The script works properly but the output of the wget
line which is printed to screen is supposed to also be tee
'ed to the log, but for some reason only it isn't being written to the log.
Example:
[root@sjorigin1 ~]# tailf /var/log/test_ftp_akamai.log
25-02-15 02:10:31 -----===== Start =====------
25-02-15 02:10:33 -----===== Done =====------
25-02-15 02:10:33 -----===== Start =====------
25-02-15 02:10:35 -----===== Done =====------
Can you find the reason for the fact that it is not written to the log?
Thanks in advance,