当前位置: 技术问答>linux和unix
linux进程中备份文件的问题
来源: 互联网 发布时间:2017-05-22
本文导语: linux进程中定时备份文件,我采用如下的方法 system("cp -f /data/configure /media/nand/"); 经测试,如果configure文件比较大,进程会中断,在网上查了一下资料,说system函数会调用fork函数创建一个进程,等该进程结束后才返...
linux进程中定时备份文件,我采用如下的方法
经测试,如果configure文件比较大,进程会中断,在网上查了一下资料,说system函数会调用fork函数创建一个进程,等该进程结束后才返回主进程。
备份文件有没有其他的方法?
system("cp -f /data/configure /media/nand/");
经测试,如果configure文件比较大,进程会中断,在网上查了一下资料,说system函数会调用fork函数创建一个进程,等该进程结束后才返回主进程。
备份文件有没有其他的方法?
|
If this C program is solely for backup, then you have tons of easier alternatives to achieve this goal.
Cronjob+bash/python/perl, whatever.
If you have to do it in C but you don't want the program wait for system call to return. You may simply fork a child process and call system in the child. If the parent is a daemon, you will have to call waitpid sometime in case OS keeps too many zombies for your program.
All in all, it's not worth your effort to have this backup function using C...
Cronjob+bash/python/perl, whatever.
If you have to do it in C but you don't want the program wait for system call to return. You may simply fork a child process and call system in the child. If the parent is a daemon, you will have to call waitpid sometime in case OS keeps too many zombies for your program.
All in all, it's not worth your effort to have this backup function using C...
|
有没有试过使用 open 创建一个新文件,read write来完成备份?open打开的时候指定O_LARGEFILE选项,参阅下man page 好像要添加一个宏定义