V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
beric
V2EX  ›  Linux

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

  •  
  •   beric · 2017-03-09 10:12:42 +08:00 · 2739 次点击
    这是一个创建于 2576 天前的主题,其中的信息可能已经有所发展或是发生改变。
    想自动备份远程服务器上的文件(大约 1GB 左右),写了一个 except scp 的脚本,用 crond 定时执行。
    但之后检查发现本地保存的文件只有几十 M ,文件没有传完就停止了。查看远程服务器端的 LOG ,显示:
    Received disconnect from xxxx disconnected by user
    大概连接了 10s 这样
    查看本地 log 没看到相关出错或退出的信息。求解……
    11 条回复    2017-03-10 08:34:12 +08:00
    xiaket
        1
    xiaket  
       2017-03-09 10:25:05 +08:00
    use rsync and retry till the exit code is 0.
    beric
        2
    beric  
    OP
       2017-03-09 11:04:54 +08:00
    @xiaket 想问一下这样做是为了防止连接被断开?想知道连接了 10s 就断开是什么原因(客户端网络?系统 KILL 掉?),有没有一个跟踪思路呢?谢谢
    goodryb
        3
    goodryb  
       2017-03-09 11:10:03 +08:00
    这种为何不用 rsync
    goodryb
        4
    goodryb  
       2017-03-09 11:10:42 +08:00
    @beric #2 手动执行一下看看
    lgpqdwjh
        5
    lgpqdwjh  
       2017-03-09 11:16:18 +08:00
    nohup $command > $PATH/$LOG_FILE 2>&1 &
    artandlol
        6
    artandlol  
       2017-03-09 11:31:40 +08:00
    你用的应该不是 centos
    过程输出到 /dev/null
    tolerance
        7
    tolerance  
       2017-03-09 11:35:25 +08:00
    set timeout 60
    beric
        8
    beric  
    OP
       2017-03-09 13:49:00 +08:00
    手动执行没问题,加了&后台执行也会出现断掉的情况
    beric
        9
    beric  
    OP
       2017-03-09 13:50:29 +08:00
    @lgpqdwjh 后来我试了 nohup ,但也是断了, LOG 信息也看不出原因。想问一下还有什么方法跟踪到原因?
    floopy
        10
    floopy  
       2017-03-09 23:29:14 +08:00
    1. expect 时你是否检查了 scp 进度。
    2.rsync
    beric
        11
    beric  
    OP
       2017-03-10 08:34:12 +08:00 via Android
    @tolerance 好的谢谢,好像的确是这个问题导致
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3043 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:38 · PVG 22:38 · LAX 07:38 · JFK 10:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.