LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   save a process in linux (https://www.linuxquestions.org/questions/linux-newbie-8/save-a-process-in-linux-844634/)

ghantauke 11-16-2010 10:54 AM

save a process in linux
 
I've been running my shellscript for about half an hour now. It's taking longer than I thought to process all the data. I have the process ID of it. Is it possible to save the process and log out then log in and continue the process? I know how to pause a process using kill -pause pID and continue it using kill -cont pID. But that only work if you don't log out after pausing it. Any kind of help would be appreciated.

fordeck 11-16-2010 11:02 AM

I'm not sure about your current process, however in the future you can use a great utility called "screen". Using this program you can detach from a shell and come back to it later.

Regards,

Fordeck

Tinkster 11-16-2010 11:34 AM

Quote:

Originally Posted by ghantauke (Post 4160837)
I've been running my shellscript for about half an hour now. It's taking longer than I thought to process all the data. I have the process ID of it. Is it possible to save the process and log out then log in and continue the process? I know how to pause a process using kill -pause pID and continue it using kill -cont pID. But that only work if you don't log out after pausing it. Any kind of help would be appreciated.

No, that can't be done ...
As fordeck said - use "screen" in the future.



Cheers,
Tink

colucix 11-16-2010 11:39 AM

If the process has no connection with standard input, you can try the disown built-in. Using option -h it marks the job leaving it immune from hang-up signals (like those ones sent upon logout). In practice disown detaches the job from the parent shell and it will continue to run independently from what happens to the shell that can be terminated.

Please, note that disown may not work on stopped (paused) jobs: maybe it's safer to keep it running.

You can give it a try, but I second the suggestion given by fordeck: the screen utility is very suitable for this kind of operations. Take in mind that you can resume a screen session even from another (remote) machine and you can still watch the standard output (not possible with disown, since in this case the connection between the standard output and the terminal is definitively lost).

stress_junkie 11-16-2010 11:41 AM

I would want to experiment with this first but I think that the bash builtin command called disown might work.
http://linux.die.net/man/1/bash
Quote:

disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of active jobs. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

ghantauke 11-17-2010 08:55 AM

Thanks for the reply everyone. I'll be sure to use screen next time.


All times are GMT -5. The time now is 11:56 AM.