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

[ Linux]能否保存正在运行的进程到文件,重启后再继续运行

  •  1
     
  •   algas · Oct 19, 2015 · 3987 views
    This topic created in 3857 days ago, the information mentioned may be changed or developed.
    不知道加一些限定条件会不会让这个事情变得容易:
    首先程序是用 C 写的,而且只用到了 C 的标准库。
    其次没有多线程和进程间通信。

    其实就是想应付一下偶然的停电,毕竟把程序里所有变量输出再读入的方法太闹心了
    14 replies    2015-11-02 06:18:49 +08:00
    Orzzzz
        1
    Orzzzz  
       Oct 20, 2015
    你说的是休眠吗?
    zhicheng
        2
    zhicheng  
       Oct 20, 2015
    UPS
    algas
        3
    algas  
    OP
       Oct 20, 2015
    @Orzzzz
    对,非常类似,只是我只需要保存我的计算程序
    algas
        4
    algas  
    OP
       Oct 20, 2015
    @zhicheng 死机,机房空调挂了,被管理员杀了,别人的程序内存溢出了,着急算别的高优先任务等情况也在考虑范围内
    little_cup
        5
    little_cup  
       Oct 20, 2015
    简单粗暴的办法应该是虚拟机快照吧。
    zhicheng
        6
    zhicheng  
       Oct 20, 2015
    @algas Good Luck
    skydiver
        7
    skydiver  
       Oct 20, 2015 via Android
    docker
    mikale
        8
    mikale  
       Oct 20, 2015
    设计一个数据结构,然后开一个线程,时不时 flush 到硬盘上,启动程序的时候,从这个硬盘读取文件到内存。这是最简单的数据库运用的机制。
    owwlo
        9
    owwlo  
       Oct 20, 2015
    chinvo
        10
    chinvo  
       Oct 20, 2015
    docker 或者其他虚拟化技术
    algas
        11
    algas  
    OP
       Oct 22, 2015
    @skydiver
    @chinvo

    @mikale
    @owwlo

    投奔了 docker
    algas
        12
    algas  
    OP
       Oct 26, 2015
    @skydiver
    @chinvo

    貌似 docker 不行的样子,我在容器中运行程序,但是在 stop 容器后,里面的程序并不是被暂停,而是被杀掉了,是不是我的姿势有问题?
    onlyxuyang
        13
    onlyxuyang  
       Oct 29, 2015
    能想到的只有虚拟机快照... -_-...
    Arthur2e5
        14
    Arthur2e5  
       Nov 2, 2015
    https://stackoverflow.com/questions/192838/can-you-freeze-a-c-c-process-and-continue-it-on-a-different-host 有讨论。其中提到了一点,也就是 core 的信息常常是不够的。不过看你这么说,感觉还是可以 `./heavy_computation & gcore -o core $!` 试试,到时候 `gdb` 挂上再看看能不能 `continue` 吧。

    前面提到的 CRIU 看网页好像是个好主意。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1002 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 100ms · UTC 19:46 · PVG 03:46 · LAX 12:46 · JFK 15:46
    ♥ Do have faith in what you're doing.