7

I ran scratch-text-editor in terminal, but now I want to close the terminal without closing scratch.

Is this possible, if so; how?

8

You can use:

  1. nohup

    nohup scratch-text-editor /path/to/file &
    

    Then close terminal with Ctrl+D

    If you want direct in single command: Use exit at the end of the command. like,

    nohup scratch-text-editor /path/to/file & exit
    
  2. setsid

    setsid scratch-text-editor /path/to/file ; exit
    
  3. disown

    scratch-text-editor /path/to/file & disown ; exit
    
  4. All in one command:

    (scratch-text-editor /path/to/file &) ; exit
    
  • @Tim please try your answer once again :) – Ravan Nov 21 '15 at 16:12
  • without nohup you cant stop process with just & – Ravan Nov 21 '15 at 16:13
  • btw @Tim since you are asking for command can I add alternative commands in my answer? – Ravan Nov 21 '15 at 16:23
4

In the future use this command:

scratch-text-editor /file/to/open.txt

for this:

scratch-text-editor /file/to/open.txt &

Note the & on the end there. That will start it as a separate process.

Now to close the terminal, simply hit Ctrl + D.


If you forget to use & then you can detach it. First press Ctrl + Z to suspend the program. This can crash some, but it is unlikely.

Then type bg to send it to background, and then press Ctrl + D as above.

As a side note, instead of bg you can use %. This simply brings it back into the terminal.

  • 1
    why Ctrl+D ?........... – Ravan Nov 21 '15 at 15:51
  • @Ravan D is for Detach? Or do you mean why not just close it? That will close the application too – user3 Nov 21 '15 at 15:55
  • 1
    Actually in the first case you could still close the terminal. Go to the terminal and hit Ctrl+Z (suspend), then run 'bg' to resume the process in the background. Now you can use Ctrl+D as mentioned to close the terminal. – geckojsc Nov 21 '15 at 15:59
0

Simply detach the process from terminal's process to its parent by: command-to-run & disown

  • Mind explaining the downvote? – Paulius Šukys Nov 21 '15 at 21:43
  • 1
    The downvote was because this answer adds nothing - this is covered in previous answers. – user3 Nov 22 '15 at 14:30
0

This should work with any app opened from the terminal.

Type:

 scratch-text-editor 

After Scratch opens, type:

Ctrl + z

This will halt the process, but not close Scratch.

Next, type:

bg

This will move Scratch's process to the background.

Now, finally type:

disown

That's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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