Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
beric
V2EX  ›  Linux

用 crond 自动定时执行 except scp 脚本传输文件被停止

  •  
  •   beric · Mar 9, 2017 · 4065 views
    This topic created in 3528 days ago, the information mentioned may be changed or developed.
    想自动备份远程服务器上的文件(大约 1GB 左右),写了一个 except scp 的脚本,用 crond 定时执行。
    但之后检查发现本地保存的文件只有几十 M ,文件没有传完就停止了。查看远程服务器端的 LOG ,显示:
    Received disconnect from xxxx disconnected by user
    大概连接了 10s 这样
    查看本地 log 没看到相关出错或退出的信息。求解……
    11 replies  •  2017-03-10 08:34:12 +08:00
    xiaket
    xiaket
    Mar 9, 2017
    1
    use rsync and retry till the exit code is 0.
    beric
    beric
    OP
    Mar 9, 2017
    2
    @xiaket 想问一下这样做是为了防止连接被断开?想知道连接了 10s 就断开是什么原因(客户端网络?系统 KILL 掉?),有没有一个跟踪思路呢?谢谢
    goodryb
    goodryb
    Mar 9, 2017
    3
    这种为何不用 rsync
    goodryb
    goodryb
    Mar 9, 2017
    4
    @beric #2 手动执行一下看看
    RealLiuSha
    RealLiuSha
    Mar 9, 2017
    5
    nohup $command > $PATH/$LOG_FILE 2>&1 &
    artandlol
    artandlol
    Mar 9, 2017
    6
    你用的应该不是 centos
    过程输出到 /dev/null
    tolerance
    tolerance
    Mar 9, 2017
    7
    set timeout 60
    beric
    beric
    OP
    Mar 9, 2017
    8
    手动执行没问题,加了&后台执行也会出现断掉的情况
    beric
    beric
    OP
    Mar 9, 2017
    9
    @lgpqdwjh 后来我试了 nohup ,但也是断了, LOG 信息也看不出原因。想问一下还有什么方法跟踪到原因?
    floopy
    floopy
    Mar 9, 2017
    10
    1. expect 时你是否检查了 scp 进度。
    2.rsync
    beric
    beric
    OP
    Mar 10, 2017 via Android
    11
    @tolerance 好的谢谢,好像的确是这个问题导致
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3056 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 04:39 · PVG 12:39 · LAX 20:39 · JFK 23:39
    ♥ Do have faith in what you're doing.