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

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

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

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

    @mikale
    @owwlo

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

    貌似 docker 不行的样子,我在容器中运行程序,但是在 stop 容器后,里面的程序并不是被暂停,而是被杀掉了,是不是我的姿势有问题?
    onlyxuyang
    onlyxuyang
    Oct 29, 2015
    13
    能想到的只有虚拟机快照... -_-...
    Arthur2e5
    Arthur2e5
    Nov 2, 2015
    14
    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   ·   Privacy   ·   Solana   ·   1340 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 21:00 · PVG 05:00 · LAX 13:00 · JFK 16:00
    ♥ Do have faith in what you're doing.