• #!/bin/bash
  • PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin;
  • rm -rf /root/testfile/.
  • cd /root/testfile/
  • date >> /root/test.txt
  • /usr/bin/lftp -u root,password sftp://123.123.123.123 -e "pget -n 30 /root/ubuntu-16.04-server-amd64.template;exit" >> /root/test.txt复制代码

上面代码保存成/root/test.sh
直接执行能够在test.txt写入:
2016年 05月 17日 星期二 15:50:55 CST
113242320 bytes transferred in 22 seconds (5.02M/s)

但是用crontab执行的话
/5 * sh /root/test.sh > /dev/null 2>&1

test.txt里只有“2016年 05月 17日 星期二 15:50:55 CST”,没有“113242320 bytes transferred in 22 seconds (5.02M/s)”。

看路由器流量图是有流量的