Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How can I disown a running process and associate it to a new screen shell?

The problem is that the process is not a job inside of my active shell (as I've logged in from remote because my X-system has crashed), meaning: I guess disown, nohup, CTRL+Z & bg, screen et al. will not work.

Motivation: I started a long running job inside of a gnome-terminal. I want to detach it from the its parent, as I the X-system has crashed. I fear when I kill the X-system, also the Gnome Desktop + Gnome-Terminal + my precious script will be lost. So I still can login from remote and want to save the script process and restart X. How do I do that?

share|improve this question

marked as duplicate by Gilles, Renan, jasonwryan, Michael Mrozek Sep 5 '12 at 19:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
See e.g. serverfault.com/questions/24425/… for an answer. –  jofel Aug 30 '12 at 13:36
    
Please take a look at similar question at SuperUser superuser.com/questions/1674/… –  hostmaster Aug 30 '12 at 18:35
    
@jofel: severfaults answer uses disown, which does not work for jobs outside of your current shell. –  math Aug 31 '12 at 13:11
    
@hostmaster: The answer you selected could solve my problem but will only work for X-applications. I want it to work with any application. –  math Aug 31 '12 at 13:12
    
@Gilles: Did I said that screen does not work afterwards? –  math Aug 31 '12 at 13:13

1 Answer 1

up vote 1 down vote accepted

Depending on the scripting language you use to run the job you could use

setpgrp()
Perl: setpgrp PID, PGRP

to detach the running process from the controlling terminal, so once it starts the controlling terminal can exit without harming the running process.

Now from what you are describing you will have the controlling terminal and shell by running Gnome Terminal and starting your job from there so nohup should work just fine for you.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.