LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-16-2010, 11:54 AM   #1
ghantauke
Member
 
Registered: Nov 2010
Posts: 114

Rep: Reputation: 6
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.

Last edited by ghantauke; 11-16-2010 at 11:57 AM. Reason: to clarify the point
 
Old 11-16-2010, 12:02 PM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
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
 
Old 11-16-2010, 12:34 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by ghantauke View Post
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
 
Old 11-16-2010, 12:39 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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).

Last edited by colucix; 11-16-2010 at 12:56 PM. Reason: added note on stopped jobs
 
Old 11-16-2010, 12:41 PM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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.
 
Old 11-17-2010, 09:55 AM   #6
ghantauke
Member
 
Registered: Nov 2010
Posts: 114

Original Poster
Rep: Reputation: 6
Thanks for the reply everyone. I'll be sure to use screen next time.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Transferring from save file to save partition hda7 Puppy 2 05-04-2010 09:11 AM
Java process VS Linux process. sanu_sasidharan Linux - Server 3 10-27-2009 08:47 AM
Finding the Process ID of a Process While Initiating the Process senthilmuthiah Linux - Newbie 7 04-02-2009 11:37 AM
iptables-save can't save settings Actionscript3 Linux - Software 4 01-29-2009 11:26 AM
LXer: Will Linux Defenders Save Linux from Microsoft? LXer Syndicated Linux News 0 12-11-2008 06:30 AM


All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration