How to keep processes running after ending ssh session? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to use screen command?Keep running a python program even after logging-off the ssh sessionExecute java from terminal and let it run even after the ssh session endsKeep running a program in terminal over SSH after “Write failed: Broken pipe”How to run an application on a headless Ubuntu?Run process after exiting puttyhow to leave a process running in backgroun on a terminalLeave Ubuntu server to compute in backgroundHow Should I Be Accessing My Server?Run a program background even close the ssh connectionHow to restore a process after logging out of ssh connection?Is it possible to continue an ssh session upon each re-connection?SSH'ing to my machine attaches an existing screen session and detaching it ends my SSH sessionKeep the running processes alive when disconneting the remote connectionShare SSH Session at loginRecognize when ssh session closedrecover ssh session connectionForward X session over SSH for an already-running program?trigger x-gnome-autostart after reboot over sshRunning a process through SSH command and keeping it alive

What are these Gizmos at Izaña Atmospheric Research Center in Spain?

What information about me do stores get via my credit card?

Simulation of a banking system with an Account class in C++

Problems with Ubuntu mount /tmp

Is there a writing software that you can sort scenes like slides in PowerPoint?

Didn't get enough time to take a Coding Test - what to do now?

Semisimplicity of the category of coherent sheaves?

Can the DM override racial traits?

Create an outline of font

Is every episode of "Where are my Pants?" identical?

Can undead you have reanimated wait inside a portable hole?

"... to apply for a visa" or "... and applied for a visa"?

I could not break this equation. Please help me

What can I do if neighbor is blocking my solar panels intentionally?

Match Roman Numerals

Who or what is the being for whom Being is a question for Heidegger?

What's the point in a preamp?

How to stretch delimiters to envolve matrices inside of a kbordermatrix?

How can I protect witches in combat who wear limited clothing?

Road tyres vs "Street" tyres for charity ride on MTB Tandem

Why can't devices on different VLANs, but on the same subnet, communicate?

Why is superheterodyning better than direct conversion?

Derivation tree not rendering

He got a vote 80% that of Emmanuel Macron’s



How to keep processes running after ending ssh session?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to use screen command?Keep running a python program even after logging-off the ssh sessionExecute java from terminal and let it run even after the ssh session endsKeep running a program in terminal over SSH after “Write failed: Broken pipe”How to run an application on a headless Ubuntu?Run process after exiting puttyhow to leave a process running in backgroun on a terminalLeave Ubuntu server to compute in backgroundHow Should I Be Accessing My Server?Run a program background even close the ssh connectionHow to restore a process after logging out of ssh connection?Is it possible to continue an ssh session upon each re-connection?SSH'ing to my machine attaches an existing screen session and detaching it ends my SSH sessionKeep the running processes alive when disconneting the remote connectionShare SSH Session at loginRecognize when ssh session closedrecover ssh session connectionForward X session over SSH for an already-running program?trigger x-gnome-autostart after reboot over sshRunning a process through SSH command and keeping it alive



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








592















Let's say I launch a bunch of processes from a ssh session. Is it possible to terminate the ssh session while keeping those processes running on the remote machine?










share|improve this question

















  • 2





    Related: unix.stackexchange.com/questions/4004/…

    – Anton Tarasenko
    Nov 23 '17 at 9:23

















592















Let's say I launch a bunch of processes from a ssh session. Is it possible to terminate the ssh session while keeping those processes running on the remote machine?










share|improve this question

















  • 2





    Related: unix.stackexchange.com/questions/4004/…

    – Anton Tarasenko
    Nov 23 '17 at 9:23













592












592








592


411






Let's say I launch a bunch of processes from a ssh session. Is it possible to terminate the ssh session while keeping those processes running on the remote machine?










share|improve this question














Let's say I launch a bunch of processes from a ssh session. Is it possible to terminate the ssh session while keeping those processes running on the remote machine?







ssh






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 21 '10 at 12:09









Olivier LalondeOlivier Lalonde

21.3k51112141




21.3k51112141







  • 2





    Related: unix.stackexchange.com/questions/4004/…

    – Anton Tarasenko
    Nov 23 '17 at 9:23












  • 2





    Related: unix.stackexchange.com/questions/4004/…

    – Anton Tarasenko
    Nov 23 '17 at 9:23







2




2





Related: unix.stackexchange.com/questions/4004/…

– Anton Tarasenko
Nov 23 '17 at 9:23





Related: unix.stackexchange.com/questions/4004/…

– Anton Tarasenko
Nov 23 '17 at 9:23










14 Answers
14






active

oldest

votes


















679





+100









You should look for modern alternatives like tmux.



tmux is superior to screen for many reasons, here are just some examples:



  • Windows can be moved between session and even linked to multiple sessions

  • Windows can be split horizontally and vertically into panes

  • Support for UTF-8 and 256 colour terminals

  • Sessions can be controlled from the shell without the need to enter a session

Basic Functionality



To get the same functionality as explained in the answer recommending screen, you would need to do the following:



  • ssh into the remote machine

  • start tmux by typing tmux into the shell

  • start the process you want inside the started tmux session

  • leave/detach the tmux session by typing Ctrl+b and then d

You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.



If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.



tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.






share|improve this answer




















  • 3





    @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

    – Lekensteyn
    Nov 25 '12 at 10:31






  • 4





    This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

    – cxrodgers
    Dec 25 '12 at 8:31






  • 14





    I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

    – Mert Nuhoglu
    Aug 22 '14 at 14:53






  • 3





    Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

    – muru
    Nov 3 '14 at 3:27






  • 4





    Alternatively, run tmux detach instead of typing ctrl-b d

    – Andrew MacFie
    Nov 3 '15 at 22:51


















271














Option 1: nohup



The best way is often the simplest.



nohup long-running-command &


It was made specifically for this, it even logs stdout to nohup.log.



man nohup


Option 2: bg



If you want to "background" some already running tasks, then your best bet is to Ctrl+Z then run



bg


to put your most recent suspended task to background, allowing it to continue running.



Then a quick disown should keep the process running after you log out.



screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.



Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.






share|improve this answer




















  • 3





    I would recommend to do disown -h

    – Michele
    Aug 21 '17 at 16:45











  • interestingly screen and tmux doesn't work for miner, bur nohup works

    – Yasin Okumuş
    Nov 1 '17 at 19:04






  • 1





    bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

    – BrianHVB
    Sep 11 '18 at 23:42











  • this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

    – kilgoretrout
    Oct 25 '18 at 5:11











  • This worked for me, thank you so much

    – Chad
    Mar 24 at 3:20


















197














You could do that by using screen.



Type man screen to find out more or read this screen man page.



Simple scenario:



  • ssh into your remote box. Type screen Then start the process you want.


  • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.


  • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process.






share|improve this answer




















  • 32





    I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

    – David Oneill
    Nov 24 '12 at 22:37











  • The link is down

    – Gab是好人
    Sep 16 '16 at 13:50






  • 1





    Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

    – Max von Hippel
    Nov 1 '17 at 3:30











  • Combination with screen -S before leave and screen -r when coming back is amazing!

    – Meloman
    Mar 14 '18 at 10:03












  • Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

    – Michael Sorensen
    May 13 '18 at 19:53


















79














Screen and nohup is the better way, but if you have to detach a process already running without screen or nohup you can run disown command.




disown [-ar] [-h] [jobspec… |pid… ]



Without options, remove each jobspec from the table of active jobs. If the -h option is given, the job 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 jobspec is not 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.




With disown you can close the terminal and get the process running on the machine.






share|improve this answer




















  • 10





    This is also my favourite way to do it. I frequently use disown -a && exit

    – Stefano Palazzo
    Oct 21 '10 at 17:45






  • 1





    Perfect. This is a lovely command and deserves all the upvotes!

    – Greg
    Apr 29 '14 at 10:38






  • 8





    one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

    – HDave
    Sep 23 '14 at 21:07






  • 3





    May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

    – jiggunjer
    Aug 25 '16 at 12:42







  • 1





    This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

    – q0rban
    Aug 17 '17 at 0:24


















47














I was stuck in a large mv so I wasn't in a position to stop the process, setup screen and then start it again. I managed to exit the ssh session with the process running by essentially doing the following steps:



  1. ssh [server]

  2. command


  3. Ctrl+Z

  4. bg

  5. disown [process pid optional, defaults to last]

  6. exit

Step 3 pauses the current process (e.g. my 'mv' command).

Step 4 puts the paused process in to the background and resumes it.

Step 5 lets you disown the process.** To get a list of jobs simply type jobsbefore.




** Regarding disown (from bash manual):



disown [-ar] [-h] [jobspec ... | pid ... ]
Without options, remove each jobspec from the table of active
jobs. If jobspec is not present, and neither the -a nor the -r
option is supplied, the current job is used. 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 supplied, the -a option
means to remove or mark all jobs; the -r option without a job‐
spec argument restricts operation to running jobs. The return
value is 0 unless a jobspec does not specify a valid job.





share|improve this answer




















  • 2





    Built-in's are always my first choice :) THX

    – ken_oy
    Apr 2 '18 at 13:30











  • This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

    – Ulrich-Lorenz Schlüter
    Apr 5 '18 at 11:41











  • This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

    – Deepali Mittal
    May 14 '18 at 10:54







  • 1





    @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

    – David Foerster
    Oct 29 '18 at 16:13


















20














There are two major programs you can use to maintain programs and terminal state over multiple ssh connections. They are screen (the incumbent, but unfortunately unmaintained. Apparently being actively developed now) and tmux (newer, actively maintained). Byobu is a front end that can run on top of their of these systems and offer additional ubuntu status information. On new installations it will use tmux as a backend, if you have an older installation of byobu and an existing config it will maintain the previous backend, be it screen or tmux.



Byobu



Byobu can be installed on the computer by doing so in a Debian-based machine:



sudo aptitude install byobu


Using yum, you do



su -c 'yum install byobu'


It's also possible to install byobu on other distributions.



Using byobu



You can start byobu by running byobu on the host machine after connecting using ssh.
This will give you a shell that looks like this:



image-byobu



You can also use Byobu Terminal on a Ubuntu machine with -X option and easily have a perfectly working byobu.



Usage:



Start byobu by typing byobu.



You can press F2 to create a new window within the current session, F3-F4 to switch between the various windows.



The best part about byobu is, you dont have to actually kill the processes running in the terminal to leave the terminal. You can simply send screen/tmux (the skeleton of byobu) to background and resume the next time you come:



  • To leave byobu and keeep it running (detach) press F6.


  • The next time you come, just do byobu and you sholud be back right where you were.



    byobu-detach-attach



You can also create various byobu sessions by byobu -S session1 and so on. And you can connect to either of them when you come back.



You can do much more using Byobu. Use it!
Some definitive guides are here, or here.






share|improve this answer

























  • I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

    – jfmessier
    Nov 6 '13 at 17:47






  • 1





    @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

    – SiddharthaRT
    Nov 7 '13 at 10:40











  • This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

    – Dev
    Jul 22 '16 at 6:53


















17














You cannot do this once the process has started, you need to have set things up before you run a long running job.



You can use nohup but modern wisdom suggests you use screen or byobu as your login so you can detach and leave things running.



Screen has the advantage that you can detach from one machine and reattach from another which is handy if you want to check on long running processes that run beyond the end of the working day.



There is a reasonable getting started guide to screen here.



byobu puts an easy to use interface on top of screen with menus etc. It's also the current implementation of screen on newer ubuntu. F2 to start a new terminal F3/F4 to toggle back and forth and F6 to disconnect. Type exit to actually end terminals permanently.






share|improve this answer

























  • byobu uses tmux these days..

    – scottl
    Nov 28 '12 at 7:04






  • 12





    "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

    – Rich
    May 23 '13 at 16:11











  • after struggling to learn screen and tmux....byobu brought tears to my eyes

    – HDave
    Sep 23 '14 at 21:06











  • disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

    – mimoralea
    Nov 21 '17 at 20:49


















8














Hey, while I agreed that screen is the most efective option.
You can use vncserver and then start the process on it.



Also if your only interes is to have the process running and no need to take control back of it, and utterly most important you were not aware you will need to close the session and you have the process already running, you are not of luck if you used bash as the shell



First you need to send the process to background by typing Ctrl+Z followed by bg %1 (the number depends on the job number, usually it is 1, but you can easily pull the list using the command jobs)



Finally invoke the command disown (followed by the jobid ... same as with bg command)



This will remove the parent-child relationship between your shell and the process in background, preventing it to die when your shell is terminated.






share|improve this answer


















  • 2





    This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

    – jwbensley
    Aug 10 '12 at 17:13







  • 1





    Simply bg (without %1) is often enough, since the default is the current job

    – Walter Tross
    Nov 23 '12 at 21:55











  • It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

    – Krazy Glew
    Jul 12 '18 at 23:02



















8














For a single shell script that I have running over a long period of time, I will login, and run the process in the background using '&'.



Example:



/path/to/my/script &


I've logged out and disconnected my SSH session. When I log in some time later, the script is still executing as proven by continuous data collection from the script.






share|improve this answer


















  • 3





    Yes, I would like to know how screen / tmux is better than this simple solution.

    – Mads Skjern
    Mar 16 '15 at 8:51











  • Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

    – Daniel Pinyol
    Apr 22 '16 at 13:08






  • 1





    @MadsSkjern Because you can't enter any input into the script using this method.

    – Ken Sharp
    Feb 10 '17 at 22:18






  • 1





    @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

    – DarkCygnus
    Aug 24 '17 at 16:20


















4














You should check out GNU Screen and see if it helps you. Depending on how you need you application to run in realtime, it may cause more issues than it solves, but at least it will allow you to resume your session as if you never left it.



How to use :



  • Use the command screen for the first start, scroll through the introduction messages, you should be handed a terminal.

  • C-a C-c opens another terminal

  • C-a C-k kills a terminal

  • You can use C-a C-Space and C-a C-Backspace to cycle through terminals

  • C-a C-a is handy if you're mostly using only two terminals

  • C-a C-d detachs the current screen session and exits screens. You can then use screen -r to resume that session. You can have several detached screen sessions at once, in this case you'll be displayed a list of available sessions.

There are many other options, for example split screens, and also all shortcuts are fully customizable.






share|improve this answer






























    3














    Simplest answer...



    ctrl+z will suspend the running program



    "bg" will run it in the background






    share|improve this answer


















    • 5





      Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

      – Eliah Kagan
      Aug 13 '13 at 0:32






    • 3





      On my Ubuntu server, with default setup, it really does keep running!

      – Mads Skjern
      Mar 16 '15 at 8:53


















    3














    The easiest way is to run your command in the background with &. Then just write:



    disown -a





    share|improve this answer
































      0














      While everyone says to use disown (the only option you have after you already started the process), nohup, or even running the command in screen, which is useful if you want to see all the output from the command... I'm a fan of screen.. I still have tried most recent mainstream distributions of Linux and simply putting the job in the background and quitting does not cause all the processes that are running to die. There must be a global setting or something. I'm trying this on some pretty old systems (slackware 12) and my test script keeps running until I manually kill it:



      shell$ cat > test.pl

      #!/usr/bin/perl
      while(1)
      sleep(1);

      shell$ perl ./test.pl &
      shell$ exit
      logout
      shell$ ps aux test.pl
      mymom 31337 1 0 13:25 ? 00:00:00 perl ./test.pl
      shell$


      While I agree that screen would be the best way to run this, even if my script wrote to log files or whatever.. I've never needed to use disown -a or nohup unless it was out of complete paranoia. Maybe someone can shed some light on how bash behaves by default? Maybe some system administrators change the defaults on large shells to keep their users' processes from overloading the system?






      share|improve this answer

























      • If you have any further query please ask it as a new question

        – heemayl
        Jul 30 '15 at 2:05


















      -1














      Instead of :



      cmd options; 


      Add before nohup :



      nohup cmd options & 


      Then, you will be able to see the console stdout by :



      tail -f nohup.out





      share|improve this answer





















        protected by heemayl Sep 16 '15 at 20:52



        Thank you for your interest in this question.
        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



        Would you like to answer one of these unanswered questions instead?














        14 Answers
        14






        active

        oldest

        votes








        14 Answers
        14






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        679





        +100









        You should look for modern alternatives like tmux.



        tmux is superior to screen for many reasons, here are just some examples:



        • Windows can be moved between session and even linked to multiple sessions

        • Windows can be split horizontally and vertically into panes

        • Support for UTF-8 and 256 colour terminals

        • Sessions can be controlled from the shell without the need to enter a session

        Basic Functionality



        To get the same functionality as explained in the answer recommending screen, you would need to do the following:



        • ssh into the remote machine

        • start tmux by typing tmux into the shell

        • start the process you want inside the started tmux session

        • leave/detach the tmux session by typing Ctrl+b and then d

        You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.



        If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.



        tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.






        share|improve this answer




















        • 3





          @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

          – Lekensteyn
          Nov 25 '12 at 10:31






        • 4





          This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

          – cxrodgers
          Dec 25 '12 at 8:31






        • 14





          I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

          – Mert Nuhoglu
          Aug 22 '14 at 14:53






        • 3





          Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

          – muru
          Nov 3 '14 at 3:27






        • 4





          Alternatively, run tmux detach instead of typing ctrl-b d

          – Andrew MacFie
          Nov 3 '15 at 22:51















        679





        +100









        You should look for modern alternatives like tmux.



        tmux is superior to screen for many reasons, here are just some examples:



        • Windows can be moved between session and even linked to multiple sessions

        • Windows can be split horizontally and vertically into panes

        • Support for UTF-8 and 256 colour terminals

        • Sessions can be controlled from the shell without the need to enter a session

        Basic Functionality



        To get the same functionality as explained in the answer recommending screen, you would need to do the following:



        • ssh into the remote machine

        • start tmux by typing tmux into the shell

        • start the process you want inside the started tmux session

        • leave/detach the tmux session by typing Ctrl+b and then d

        You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.



        If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.



        tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.






        share|improve this answer




















        • 3





          @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

          – Lekensteyn
          Nov 25 '12 at 10:31






        • 4





          This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

          – cxrodgers
          Dec 25 '12 at 8:31






        • 14





          I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

          – Mert Nuhoglu
          Aug 22 '14 at 14:53






        • 3





          Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

          – muru
          Nov 3 '14 at 3:27






        • 4





          Alternatively, run tmux detach instead of typing ctrl-b d

          – Andrew MacFie
          Nov 3 '15 at 22:51













        679





        +100







        679





        +100



        679




        +100





        You should look for modern alternatives like tmux.



        tmux is superior to screen for many reasons, here are just some examples:



        • Windows can be moved between session and even linked to multiple sessions

        • Windows can be split horizontally and vertically into panes

        • Support for UTF-8 and 256 colour terminals

        • Sessions can be controlled from the shell without the need to enter a session

        Basic Functionality



        To get the same functionality as explained in the answer recommending screen, you would need to do the following:



        • ssh into the remote machine

        • start tmux by typing tmux into the shell

        • start the process you want inside the started tmux session

        • leave/detach the tmux session by typing Ctrl+b and then d

        You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.



        If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.



        tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.






        share|improve this answer















        You should look for modern alternatives like tmux.



        tmux is superior to screen for many reasons, here are just some examples:



        • Windows can be moved between session and even linked to multiple sessions

        • Windows can be split horizontally and vertically into panes

        • Support for UTF-8 and 256 colour terminals

        • Sessions can be controlled from the shell without the need to enter a session

        Basic Functionality



        To get the same functionality as explained in the answer recommending screen, you would need to do the following:



        • ssh into the remote machine

        • start tmux by typing tmux into the shell

        • start the process you want inside the started tmux session

        • leave/detach the tmux session by typing Ctrl+b and then d

        You can now safely log off from the remote machine, your process will keep running inside tmux. When you come back again and want to check the status of your process you can use tmux attach to attach to your tmux session.



        If you want to have multiple sessions running side-by-side, you should name each session using Ctrl+b and $. You can get a list of the currently running sessions using tmux list-sessions, now attach to a running session with command tmux attach-session -t 0.



        tmux can do much more advanced things than handle a single window in a single session. For more information have a look in man tmux or the tmux GitHub page. In particular, here's an FAQ about the main differences between screen and tmux.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 4 '18 at 9:34









        ᴄʀᴏᴢᴇᴛ

        1033




        1033










        answered Nov 23 '12 at 9:26









        tongputongpu

        7,4391912




        7,4391912







        • 3





          @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

          – Lekensteyn
          Nov 25 '12 at 10:31






        • 4





          This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

          – cxrodgers
          Dec 25 '12 at 8:31






        • 14





          I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

          – Mert Nuhoglu
          Aug 22 '14 at 14:53






        • 3





          Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

          – muru
          Nov 3 '14 at 3:27






        • 4





          Alternatively, run tmux detach instead of typing ctrl-b d

          – Andrew MacFie
          Nov 3 '15 at 22:51












        • 3





          @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

          – Lekensteyn
          Nov 25 '12 at 10:31






        • 4





          This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

          – cxrodgers
          Dec 25 '12 at 8:31






        • 14





          I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

          – Mert Nuhoglu
          Aug 22 '14 at 14:53






        • 3





          Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

          – muru
          Nov 3 '14 at 3:27






        • 4





          Alternatively, run tmux detach instead of typing ctrl-b d

          – Andrew MacFie
          Nov 3 '15 at 22:51







        3




        3





        @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

        – Lekensteyn
        Nov 25 '12 at 10:31





        @CraigM Use screen -x -r [screenname] or screen -rx for short if you have only one screen session active. This allows you to attach an existing screen instance.

        – Lekensteyn
        Nov 25 '12 at 10:31




        4




        4





        This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

        – cxrodgers
        Dec 25 '12 at 8:31





        This advice helped me with the same problem but I think it includes a typo. I am pretty sure that you need to type Ctrl-b and then d in order to leave/detach the tmux session. Certainly that is the case for the version of tmux on my Ubuntu 12.04.

        – cxrodgers
        Dec 25 '12 at 8:31




        14




        14





        I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

        – Mert Nuhoglu
        Aug 22 '14 at 14:53





        I made a mistake while following the above instructions. I will share it if anybody might fall into the same mistake: I started tmux in the shell of my own computer instead of the shell of the remote computer. One needs to start tmux in the shell of remote computer.

        – Mert Nuhoglu
        Aug 22 '14 at 14:53




        3




        3





        Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

        – muru
        Nov 3 '14 at 3:27





        Screen is now being developed again: lists.gnu.org/archive/html/screen-devel/2014-04/msg00024.html Could you update your answer?

        – muru
        Nov 3 '14 at 3:27




        4




        4





        Alternatively, run tmux detach instead of typing ctrl-b d

        – Andrew MacFie
        Nov 3 '15 at 22:51





        Alternatively, run tmux detach instead of typing ctrl-b d

        – Andrew MacFie
        Nov 3 '15 at 22:51













        271














        Option 1: nohup



        The best way is often the simplest.



        nohup long-running-command &


        It was made specifically for this, it even logs stdout to nohup.log.



        man nohup


        Option 2: bg



        If you want to "background" some already running tasks, then your best bet is to Ctrl+Z then run



        bg


        to put your most recent suspended task to background, allowing it to continue running.



        Then a quick disown should keep the process running after you log out.



        screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.



        Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.






        share|improve this answer




















        • 3





          I would recommend to do disown -h

          – Michele
          Aug 21 '17 at 16:45











        • interestingly screen and tmux doesn't work for miner, bur nohup works

          – Yasin Okumuş
          Nov 1 '17 at 19:04






        • 1





          bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

          – BrianHVB
          Sep 11 '18 at 23:42











        • this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

          – kilgoretrout
          Oct 25 '18 at 5:11











        • This worked for me, thank you so much

          – Chad
          Mar 24 at 3:20















        271














        Option 1: nohup



        The best way is often the simplest.



        nohup long-running-command &


        It was made specifically for this, it even logs stdout to nohup.log.



        man nohup


        Option 2: bg



        If you want to "background" some already running tasks, then your best bet is to Ctrl+Z then run



        bg


        to put your most recent suspended task to background, allowing it to continue running.



        Then a quick disown should keep the process running after you log out.



        screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.



        Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.






        share|improve this answer




















        • 3





          I would recommend to do disown -h

          – Michele
          Aug 21 '17 at 16:45











        • interestingly screen and tmux doesn't work for miner, bur nohup works

          – Yasin Okumuş
          Nov 1 '17 at 19:04






        • 1





          bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

          – BrianHVB
          Sep 11 '18 at 23:42











        • this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

          – kilgoretrout
          Oct 25 '18 at 5:11











        • This worked for me, thank you so much

          – Chad
          Mar 24 at 3:20













        271












        271








        271







        Option 1: nohup



        The best way is often the simplest.



        nohup long-running-command &


        It was made specifically for this, it even logs stdout to nohup.log.



        man nohup


        Option 2: bg



        If you want to "background" some already running tasks, then your best bet is to Ctrl+Z then run



        bg


        to put your most recent suspended task to background, allowing it to continue running.



        Then a quick disown should keep the process running after you log out.



        screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.



        Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.






        share|improve this answer















        Option 1: nohup



        The best way is often the simplest.



        nohup long-running-command &


        It was made specifically for this, it even logs stdout to nohup.log.



        man nohup


        Option 2: bg



        If you want to "background" some already running tasks, then your best bet is to Ctrl+Z then run



        bg


        to put your most recent suspended task to background, allowing it to continue running.



        Then a quick disown should keep the process running after you log out.



        screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know your going to leave behind and bg for tasks your already running and don't want to re-start.



        Keep in mind, both are bash specific. If you're not using bash, then the commands could be different.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 29 '18 at 16:15









        David Foerster

        28.6k1367113




        28.6k1367113










        answered Nov 28 '12 at 2:58









        coteyrcoteyr

        12.8k52449




        12.8k52449







        • 3





          I would recommend to do disown -h

          – Michele
          Aug 21 '17 at 16:45











        • interestingly screen and tmux doesn't work for miner, bur nohup works

          – Yasin Okumuş
          Nov 1 '17 at 19:04






        • 1





          bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

          – BrianHVB
          Sep 11 '18 at 23:42











        • this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

          – kilgoretrout
          Oct 25 '18 at 5:11











        • This worked for me, thank you so much

          – Chad
          Mar 24 at 3:20












        • 3





          I would recommend to do disown -h

          – Michele
          Aug 21 '17 at 16:45











        • interestingly screen and tmux doesn't work for miner, bur nohup works

          – Yasin Okumuş
          Nov 1 '17 at 19:04






        • 1





          bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

          – BrianHVB
          Sep 11 '18 at 23:42











        • this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

          – kilgoretrout
          Oct 25 '18 at 5:11











        • This worked for me, thank you so much

          – Chad
          Mar 24 at 3:20







        3




        3





        I would recommend to do disown -h

        – Michele
        Aug 21 '17 at 16:45





        I would recommend to do disown -h

        – Michele
        Aug 21 '17 at 16:45













        interestingly screen and tmux doesn't work for miner, bur nohup works

        – Yasin Okumuş
        Nov 1 '17 at 19:04





        interestingly screen and tmux doesn't work for miner, bur nohup works

        – Yasin Okumuş
        Nov 1 '17 at 19:04




        1




        1





        bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

        – BrianHVB
        Sep 11 '18 at 23:42





        bg + disown didn't work for me. I had a deployment script running I forgot to start inside tmux, and needed to leave early for a meeting. The script continuously outputs progress to the shell. ctrl+z stopped the process, returning me to bash. bg resumed the process, but it also resumed outputting the status to bash, making it impossible to see what I was typing. However, a disown command produced "disown: current: no such job"

        – BrianHVB
        Sep 11 '18 at 23:42













        this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

        – kilgoretrout
        Oct 25 '18 at 5:11





        this didn't work for me with julia myFile.jl for whatever reason. tmux does and is great.

        – kilgoretrout
        Oct 25 '18 at 5:11













        This worked for me, thank you so much

        – Chad
        Mar 24 at 3:20





        This worked for me, thank you so much

        – Chad
        Mar 24 at 3:20











        197














        You could do that by using screen.



        Type man screen to find out more or read this screen man page.



        Simple scenario:



        • ssh into your remote box. Type screen Then start the process you want.


        • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.


        • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process.






        share|improve this answer




















        • 32





          I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

          – David Oneill
          Nov 24 '12 at 22:37











        • The link is down

          – Gab是好人
          Sep 16 '16 at 13:50






        • 1





          Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

          – Max von Hippel
          Nov 1 '17 at 3:30











        • Combination with screen -S before leave and screen -r when coming back is amazing!

          – Meloman
          Mar 14 '18 at 10:03












        • Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

          – Michael Sorensen
          May 13 '18 at 19:53















        197














        You could do that by using screen.



        Type man screen to find out more or read this screen man page.



        Simple scenario:



        • ssh into your remote box. Type screen Then start the process you want.


        • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.


        • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process.






        share|improve this answer




















        • 32





          I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

          – David Oneill
          Nov 24 '12 at 22:37











        • The link is down

          – Gab是好人
          Sep 16 '16 at 13:50






        • 1





          Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

          – Max von Hippel
          Nov 1 '17 at 3:30











        • Combination with screen -S before leave and screen -r when coming back is amazing!

          – Meloman
          Mar 14 '18 at 10:03












        • Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

          – Michael Sorensen
          May 13 '18 at 19:53













        197












        197








        197







        You could do that by using screen.



        Type man screen to find out more or read this screen man page.



        Simple scenario:



        • ssh into your remote box. Type screen Then start the process you want.


        • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.


        • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process.






        share|improve this answer















        You could do that by using screen.



        Type man screen to find out more or read this screen man page.



        Simple scenario:



        • ssh into your remote box. Type screen Then start the process you want.


        • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.


        • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 22 '17 at 4:19









        heemayl

        68.2k11144215




        68.2k11144215










        answered Oct 21 '10 at 12:20









        LincolnLincoln

        2,49811213




        2,49811213







        • 32





          I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

          – David Oneill
          Nov 24 '12 at 22:37











        • The link is down

          – Gab是好人
          Sep 16 '16 at 13:50






        • 1





          Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

          – Max von Hippel
          Nov 1 '17 at 3:30











        • Combination with screen -S before leave and screen -r when coming back is amazing!

          – Meloman
          Mar 14 '18 at 10:03












        • Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

          – Michael Sorensen
          May 13 '18 at 19:53












        • 32





          I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

          – David Oneill
          Nov 24 '12 at 22:37











        • The link is down

          – Gab是好人
          Sep 16 '16 at 13:50






        • 1





          Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

          – Max von Hippel
          Nov 1 '17 at 3:30











        • Combination with screen -S before leave and screen -r when coming back is amazing!

          – Meloman
          Mar 14 '18 at 10:03












        • Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

          – Michael Sorensen
          May 13 '18 at 19:53







        32




        32





        I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

        – David Oneill
        Nov 24 '12 at 22:37





        I will usually name my screen sessions using screen -S name to make it easier to connect to the correct one later.

        – David Oneill
        Nov 24 '12 at 22:37













        The link is down

        – Gab是好人
        Sep 16 '16 at 13:50





        The link is down

        – Gab是好人
        Sep 16 '16 at 13:50




        1




        1





        Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

        – Max von Hippel
        Nov 1 '17 at 3:30





        Personally, I'm working on a box without any package control software. After spending about half an hour building dependencies for TMUX (which I personally have experience with and like) from source, it became clear that screen was the better and simpler solution for me. TL;DR: the optimal solution to this problem depends on the use case, the machine, and how much time you have to get set up. Thanks for this answer :)

        – Max von Hippel
        Nov 1 '17 at 3:30













        Combination with screen -S before leave and screen -r when coming back is amazing!

        – Meloman
        Mar 14 '18 at 10:03






        Combination with screen -S before leave and screen -r when coming back is amazing!

        – Meloman
        Mar 14 '18 at 10:03














        Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

        – Michael Sorensen
        May 13 '18 at 19:53





        Thanks for this. This solution worked for me while tmux did not (I use a version of bash for windows while ssh'ing into a linux machine)

        – Michael Sorensen
        May 13 '18 at 19:53











        79














        Screen and nohup is the better way, but if you have to detach a process already running without screen or nohup you can run disown command.




        disown [-ar] [-h] [jobspec… |pid… ]



        Without options, remove each jobspec from the table of active jobs. If the -h option is given, the job 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 jobspec is not 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.




        With disown you can close the terminal and get the process running on the machine.






        share|improve this answer




















        • 10





          This is also my favourite way to do it. I frequently use disown -a && exit

          – Stefano Palazzo
          Oct 21 '10 at 17:45






        • 1





          Perfect. This is a lovely command and deserves all the upvotes!

          – Greg
          Apr 29 '14 at 10:38






        • 8





          one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

          – HDave
          Sep 23 '14 at 21:07






        • 3





          May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

          – jiggunjer
          Aug 25 '16 at 12:42







        • 1





          This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

          – q0rban
          Aug 17 '17 at 0:24















        79














        Screen and nohup is the better way, but if you have to detach a process already running without screen or nohup you can run disown command.




        disown [-ar] [-h] [jobspec… |pid… ]



        Without options, remove each jobspec from the table of active jobs. If the -h option is given, the job 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 jobspec is not 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.




        With disown you can close the terminal and get the process running on the machine.






        share|improve this answer




















        • 10





          This is also my favourite way to do it. I frequently use disown -a && exit

          – Stefano Palazzo
          Oct 21 '10 at 17:45






        • 1





          Perfect. This is a lovely command and deserves all the upvotes!

          – Greg
          Apr 29 '14 at 10:38






        • 8





          one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

          – HDave
          Sep 23 '14 at 21:07






        • 3





          May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

          – jiggunjer
          Aug 25 '16 at 12:42







        • 1





          This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

          – q0rban
          Aug 17 '17 at 0:24













        79












        79








        79







        Screen and nohup is the better way, but if you have to detach a process already running without screen or nohup you can run disown command.




        disown [-ar] [-h] [jobspec… |pid… ]



        Without options, remove each jobspec from the table of active jobs. If the -h option is given, the job 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 jobspec is not 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.




        With disown you can close the terminal and get the process running on the machine.






        share|improve this answer















        Screen and nohup is the better way, but if you have to detach a process already running without screen or nohup you can run disown command.




        disown [-ar] [-h] [jobspec… |pid… ]



        Without options, remove each jobspec from the table of active jobs. If the -h option is given, the job 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 jobspec is not 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.




        With disown you can close the terminal and get the process running on the machine.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 20 '17 at 16:02









        Nick T

        1,71721327




        1,71721327










        answered Oct 21 '10 at 13:19









        bassgeybassgey

        82152




        82152







        • 10





          This is also my favourite way to do it. I frequently use disown -a && exit

          – Stefano Palazzo
          Oct 21 '10 at 17:45






        • 1





          Perfect. This is a lovely command and deserves all the upvotes!

          – Greg
          Apr 29 '14 at 10:38






        • 8





          one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

          – HDave
          Sep 23 '14 at 21:07






        • 3





          May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

          – jiggunjer
          Aug 25 '16 at 12:42







        • 1





          This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

          – q0rban
          Aug 17 '17 at 0:24












        • 10





          This is also my favourite way to do it. I frequently use disown -a && exit

          – Stefano Palazzo
          Oct 21 '10 at 17:45






        • 1





          Perfect. This is a lovely command and deserves all the upvotes!

          – Greg
          Apr 29 '14 at 10:38






        • 8





          one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

          – HDave
          Sep 23 '14 at 21:07






        • 3





          May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

          – jiggunjer
          Aug 25 '16 at 12:42







        • 1





          This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

          – q0rban
          Aug 17 '17 at 0:24







        10




        10





        This is also my favourite way to do it. I frequently use disown -a && exit

        – Stefano Palazzo
        Oct 21 '10 at 17:45





        This is also my favourite way to do it. I frequently use disown -a && exit

        – Stefano Palazzo
        Oct 21 '10 at 17:45




        1




        1





        Perfect. This is a lovely command and deserves all the upvotes!

        – Greg
        Apr 29 '14 at 10:38





        Perfect. This is a lovely command and deserves all the upvotes!

        – Greg
        Apr 29 '14 at 10:38




        8




        8





        one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

        – HDave
        Sep 23 '14 at 21:07





        one word of caution, I stopped a running process with Ctrl-Z and didn't start it in the background before calling disown and it killed it.

        – HDave
        Sep 23 '14 at 21:07




        3




        3





        May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

        – jiggunjer
        Aug 25 '16 at 12:42






        May crash if it wants to write to the terminal. Redirecting output of a running process isn't as easy. Better to start it properly with nohup.

        – jiggunjer
        Aug 25 '16 at 12:42





        1




        1





        This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

        – q0rban
        Aug 17 '17 at 0:24





        This is a good answer, because it directly answers the question. The author of the question asked what to do after having already executed a bunch of long running commands. Most of these answers let you know what to do before you execute the commands.

        – q0rban
        Aug 17 '17 at 0:24











        47














        I was stuck in a large mv so I wasn't in a position to stop the process, setup screen and then start it again. I managed to exit the ssh session with the process running by essentially doing the following steps:



        1. ssh [server]

        2. command


        3. Ctrl+Z

        4. bg

        5. disown [process pid optional, defaults to last]

        6. exit

        Step 3 pauses the current process (e.g. my 'mv' command).

        Step 4 puts the paused process in to the background and resumes it.

        Step 5 lets you disown the process.** To get a list of jobs simply type jobsbefore.




        ** Regarding disown (from bash manual):



        disown [-ar] [-h] [jobspec ... | pid ... ]
        Without options, remove each jobspec from the table of active
        jobs. If jobspec is not present, and neither the -a nor the -r
        option is supplied, the current job is used. 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 supplied, the -a option
        means to remove or mark all jobs; the -r option without a job‐
        spec argument restricts operation to running jobs. The return
        value is 0 unless a jobspec does not specify a valid job.





        share|improve this answer




















        • 2





          Built-in's are always my first choice :) THX

          – ken_oy
          Apr 2 '18 at 13:30











        • This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

          – Ulrich-Lorenz Schlüter
          Apr 5 '18 at 11:41











        • This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

          – Deepali Mittal
          May 14 '18 at 10:54







        • 1





          @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

          – David Foerster
          Oct 29 '18 at 16:13















        47














        I was stuck in a large mv so I wasn't in a position to stop the process, setup screen and then start it again. I managed to exit the ssh session with the process running by essentially doing the following steps:



        1. ssh [server]

        2. command


        3. Ctrl+Z

        4. bg

        5. disown [process pid optional, defaults to last]

        6. exit

        Step 3 pauses the current process (e.g. my 'mv' command).

        Step 4 puts the paused process in to the background and resumes it.

        Step 5 lets you disown the process.** To get a list of jobs simply type jobsbefore.




        ** Regarding disown (from bash manual):



        disown [-ar] [-h] [jobspec ... | pid ... ]
        Without options, remove each jobspec from the table of active
        jobs. If jobspec is not present, and neither the -a nor the -r
        option is supplied, the current job is used. 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 supplied, the -a option
        means to remove or mark all jobs; the -r option without a job‐
        spec argument restricts operation to running jobs. The return
        value is 0 unless a jobspec does not specify a valid job.





        share|improve this answer




















        • 2





          Built-in's are always my first choice :) THX

          – ken_oy
          Apr 2 '18 at 13:30











        • This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

          – Ulrich-Lorenz Schlüter
          Apr 5 '18 at 11:41











        • This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

          – Deepali Mittal
          May 14 '18 at 10:54







        • 1





          @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

          – David Foerster
          Oct 29 '18 at 16:13













        47












        47








        47







        I was stuck in a large mv so I wasn't in a position to stop the process, setup screen and then start it again. I managed to exit the ssh session with the process running by essentially doing the following steps:



        1. ssh [server]

        2. command


        3. Ctrl+Z

        4. bg

        5. disown [process pid optional, defaults to last]

        6. exit

        Step 3 pauses the current process (e.g. my 'mv' command).

        Step 4 puts the paused process in to the background and resumes it.

        Step 5 lets you disown the process.** To get a list of jobs simply type jobsbefore.




        ** Regarding disown (from bash manual):



        disown [-ar] [-h] [jobspec ... | pid ... ]
        Without options, remove each jobspec from the table of active
        jobs. If jobspec is not present, and neither the -a nor the -r
        option is supplied, the current job is used. 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 supplied, the -a option
        means to remove or mark all jobs; the -r option without a job‐
        spec argument restricts operation to running jobs. The return
        value is 0 unless a jobspec does not specify a valid job.





        share|improve this answer















        I was stuck in a large mv so I wasn't in a position to stop the process, setup screen and then start it again. I managed to exit the ssh session with the process running by essentially doing the following steps:



        1. ssh [server]

        2. command


        3. Ctrl+Z

        4. bg

        5. disown [process pid optional, defaults to last]

        6. exit

        Step 3 pauses the current process (e.g. my 'mv' command).

        Step 4 puts the paused process in to the background and resumes it.

        Step 5 lets you disown the process.** To get a list of jobs simply type jobsbefore.




        ** Regarding disown (from bash manual):



        disown [-ar] [-h] [jobspec ... | pid ... ]
        Without options, remove each jobspec from the table of active
        jobs. If jobspec is not present, and neither the -a nor the -r
        option is supplied, the current job is used. 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 supplied, the -a option
        means to remove or mark all jobs; the -r option without a job‐
        spec argument restricts operation to running jobs. The return
        value is 0 unless a jobspec does not specify a valid job.






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 10 at 18:50

























        answered Nov 25 '13 at 3:30









        ChaosChaos

        7501710




        7501710







        • 2





          Built-in's are always my first choice :) THX

          – ken_oy
          Apr 2 '18 at 13:30











        • This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

          – Ulrich-Lorenz Schlüter
          Apr 5 '18 at 11:41











        • This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

          – Deepali Mittal
          May 14 '18 at 10:54







        • 1





          @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

          – David Foerster
          Oct 29 '18 at 16:13












        • 2





          Built-in's are always my first choice :) THX

          – ken_oy
          Apr 2 '18 at 13:30











        • This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

          – Ulrich-Lorenz Schlüter
          Apr 5 '18 at 11:41











        • This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

          – Deepali Mittal
          May 14 '18 at 10:54







        • 1





          @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

          – David Foerster
          Oct 29 '18 at 16:13







        2




        2





        Built-in's are always my first choice :) THX

        – ken_oy
        Apr 2 '18 at 13:30





        Built-in's are always my first choice :) THX

        – ken_oy
        Apr 2 '18 at 13:30













        This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

        – Ulrich-Lorenz Schlüter
        Apr 5 '18 at 11:41





        This answer should be marked as right. To install and getting used to screen for solving this problem is exaggerated.

        – Ulrich-Lorenz Schlüter
        Apr 5 '18 at 11:41













        This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

        – Deepali Mittal
        May 14 '18 at 10:54






        This is very helpful when you have already started any command and which is being running for long. Terminating and starting it in a TMUX Session will take time

        – Deepali Mittal
        May 14 '18 at 10:54





        1




        1





        @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

        – David Foerster
        Oct 29 '18 at 16:13





        @tom-brossman: Please watch out for unnecessary edits like this one! If invoked without job specification the disown built-in command acts on the most recent background job.

        – David Foerster
        Oct 29 '18 at 16:13











        20














        There are two major programs you can use to maintain programs and terminal state over multiple ssh connections. They are screen (the incumbent, but unfortunately unmaintained. Apparently being actively developed now) and tmux (newer, actively maintained). Byobu is a front end that can run on top of their of these systems and offer additional ubuntu status information. On new installations it will use tmux as a backend, if you have an older installation of byobu and an existing config it will maintain the previous backend, be it screen or tmux.



        Byobu



        Byobu can be installed on the computer by doing so in a Debian-based machine:



        sudo aptitude install byobu


        Using yum, you do



        su -c 'yum install byobu'


        It's also possible to install byobu on other distributions.



        Using byobu



        You can start byobu by running byobu on the host machine after connecting using ssh.
        This will give you a shell that looks like this:



        image-byobu



        You can also use Byobu Terminal on a Ubuntu machine with -X option and easily have a perfectly working byobu.



        Usage:



        Start byobu by typing byobu.



        You can press F2 to create a new window within the current session, F3-F4 to switch between the various windows.



        The best part about byobu is, you dont have to actually kill the processes running in the terminal to leave the terminal. You can simply send screen/tmux (the skeleton of byobu) to background and resume the next time you come:



        • To leave byobu and keeep it running (detach) press F6.


        • The next time you come, just do byobu and you sholud be back right where you were.



          byobu-detach-attach



        You can also create various byobu sessions by byobu -S session1 and so on. And you can connect to either of them when you come back.



        You can do much more using Byobu. Use it!
        Some definitive guides are here, or here.






        share|improve this answer

























        • I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

          – jfmessier
          Nov 6 '13 at 17:47






        • 1





          @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

          – SiddharthaRT
          Nov 7 '13 at 10:40











        • This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

          – Dev
          Jul 22 '16 at 6:53















        20














        There are two major programs you can use to maintain programs and terminal state over multiple ssh connections. They are screen (the incumbent, but unfortunately unmaintained. Apparently being actively developed now) and tmux (newer, actively maintained). Byobu is a front end that can run on top of their of these systems and offer additional ubuntu status information. On new installations it will use tmux as a backend, if you have an older installation of byobu and an existing config it will maintain the previous backend, be it screen or tmux.



        Byobu



        Byobu can be installed on the computer by doing so in a Debian-based machine:



        sudo aptitude install byobu


        Using yum, you do



        su -c 'yum install byobu'


        It's also possible to install byobu on other distributions.



        Using byobu



        You can start byobu by running byobu on the host machine after connecting using ssh.
        This will give you a shell that looks like this:



        image-byobu



        You can also use Byobu Terminal on a Ubuntu machine with -X option and easily have a perfectly working byobu.



        Usage:



        Start byobu by typing byobu.



        You can press F2 to create a new window within the current session, F3-F4 to switch between the various windows.



        The best part about byobu is, you dont have to actually kill the processes running in the terminal to leave the terminal. You can simply send screen/tmux (the skeleton of byobu) to background and resume the next time you come:



        • To leave byobu and keeep it running (detach) press F6.


        • The next time you come, just do byobu and you sholud be back right where you were.



          byobu-detach-attach



        You can also create various byobu sessions by byobu -S session1 and so on. And you can connect to either of them when you come back.



        You can do much more using Byobu. Use it!
        Some definitive guides are here, or here.






        share|improve this answer

























        • I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

          – jfmessier
          Nov 6 '13 at 17:47






        • 1





          @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

          – SiddharthaRT
          Nov 7 '13 at 10:40











        • This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

          – Dev
          Jul 22 '16 at 6:53













        20












        20








        20







        There are two major programs you can use to maintain programs and terminal state over multiple ssh connections. They are screen (the incumbent, but unfortunately unmaintained. Apparently being actively developed now) and tmux (newer, actively maintained). Byobu is a front end that can run on top of their of these systems and offer additional ubuntu status information. On new installations it will use tmux as a backend, if you have an older installation of byobu and an existing config it will maintain the previous backend, be it screen or tmux.



        Byobu



        Byobu can be installed on the computer by doing so in a Debian-based machine:



        sudo aptitude install byobu


        Using yum, you do



        su -c 'yum install byobu'


        It's also possible to install byobu on other distributions.



        Using byobu



        You can start byobu by running byobu on the host machine after connecting using ssh.
        This will give you a shell that looks like this:



        image-byobu



        You can also use Byobu Terminal on a Ubuntu machine with -X option and easily have a perfectly working byobu.



        Usage:



        Start byobu by typing byobu.



        You can press F2 to create a new window within the current session, F3-F4 to switch between the various windows.



        The best part about byobu is, you dont have to actually kill the processes running in the terminal to leave the terminal. You can simply send screen/tmux (the skeleton of byobu) to background and resume the next time you come:



        • To leave byobu and keeep it running (detach) press F6.


        • The next time you come, just do byobu and you sholud be back right where you were.



          byobu-detach-attach



        You can also create various byobu sessions by byobu -S session1 and so on. And you can connect to either of them when you come back.



        You can do much more using Byobu. Use it!
        Some definitive guides are here, or here.






        share|improve this answer















        There are two major programs you can use to maintain programs and terminal state over multiple ssh connections. They are screen (the incumbent, but unfortunately unmaintained. Apparently being actively developed now) and tmux (newer, actively maintained). Byobu is a front end that can run on top of their of these systems and offer additional ubuntu status information. On new installations it will use tmux as a backend, if you have an older installation of byobu and an existing config it will maintain the previous backend, be it screen or tmux.



        Byobu



        Byobu can be installed on the computer by doing so in a Debian-based machine:



        sudo aptitude install byobu


        Using yum, you do



        su -c 'yum install byobu'


        It's also possible to install byobu on other distributions.



        Using byobu



        You can start byobu by running byobu on the host machine after connecting using ssh.
        This will give you a shell that looks like this:



        image-byobu



        You can also use Byobu Terminal on a Ubuntu machine with -X option and easily have a perfectly working byobu.



        Usage:



        Start byobu by typing byobu.



        You can press F2 to create a new window within the current session, F3-F4 to switch between the various windows.



        The best part about byobu is, you dont have to actually kill the processes running in the terminal to leave the terminal. You can simply send screen/tmux (the skeleton of byobu) to background and resume the next time you come:



        • To leave byobu and keeep it running (detach) press F6.


        • The next time you come, just do byobu and you sholud be back right where you were.



          byobu-detach-attach



        You can also create various byobu sessions by byobu -S session1 and so on. And you can connect to either of them when you come back.



        You can do much more using Byobu. Use it!
        Some definitive guides are here, or here.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 5 at 8:10









        user8261637

        32




        32










        answered Nov 24 '12 at 22:09









        SiddharthaRTSiddharthaRT

        4,99611117




        4,99611117












        • I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

          – jfmessier
          Nov 6 '13 at 17:47






        • 1





          @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

          – SiddharthaRT
          Nov 7 '13 at 10:40











        • This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

          – Dev
          Jul 22 '16 at 6:53

















        • I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

          – jfmessier
          Nov 6 '13 at 17:47






        • 1





          @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

          – SiddharthaRT
          Nov 7 '13 at 10:40











        • This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

          – Dev
          Jul 22 '16 at 6:53
















        I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

        – jfmessier
        Nov 6 '13 at 17:47





        I tried using byobu from a PuTTY-based session to my Ubuntu box, but I get the status line repeated and scrolling on the display. Although it detached properly wen pressing F6, it was not a useable solution in my setup.

        – jfmessier
        Nov 6 '13 at 17:47




        1




        1





        @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

        – SiddharthaRT
        Nov 7 '13 at 10:40





        @jfmessier It's because PuTTY doesn't take ncurses (utf-8 basically) well. It's possible to eliminate this problem by following this thread - stackoverflow.com/questions/10731099/…

        – SiddharthaRT
        Nov 7 '13 at 10:40













        This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

        – Dev
        Jul 22 '16 at 6:53





        This is awesome! 1. it gives me a colored bash prompt that I cannot seem to enable with bash as my default shell and 2. I get to run 2 bots at the same time and still have another terminal to do work on! @SiddharthaRT you deserve an upvote sir!

        – Dev
        Jul 22 '16 at 6:53











        17














        You cannot do this once the process has started, you need to have set things up before you run a long running job.



        You can use nohup but modern wisdom suggests you use screen or byobu as your login so you can detach and leave things running.



        Screen has the advantage that you can detach from one machine and reattach from another which is handy if you want to check on long running processes that run beyond the end of the working day.



        There is a reasonable getting started guide to screen here.



        byobu puts an easy to use interface on top of screen with menus etc. It's also the current implementation of screen on newer ubuntu. F2 to start a new terminal F3/F4 to toggle back and forth and F6 to disconnect. Type exit to actually end terminals permanently.






        share|improve this answer

























        • byobu uses tmux these days..

          – scottl
          Nov 28 '12 at 7:04






        • 12





          "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

          – Rich
          May 23 '13 at 16:11











        • after struggling to learn screen and tmux....byobu brought tears to my eyes

          – HDave
          Sep 23 '14 at 21:06











        • disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

          – mimoralea
          Nov 21 '17 at 20:49















        17














        You cannot do this once the process has started, you need to have set things up before you run a long running job.



        You can use nohup but modern wisdom suggests you use screen or byobu as your login so you can detach and leave things running.



        Screen has the advantage that you can detach from one machine and reattach from another which is handy if you want to check on long running processes that run beyond the end of the working day.



        There is a reasonable getting started guide to screen here.



        byobu puts an easy to use interface on top of screen with menus etc. It's also the current implementation of screen on newer ubuntu. F2 to start a new terminal F3/F4 to toggle back and forth and F6 to disconnect. Type exit to actually end terminals permanently.






        share|improve this answer

























        • byobu uses tmux these days..

          – scottl
          Nov 28 '12 at 7:04






        • 12





          "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

          – Rich
          May 23 '13 at 16:11











        • after struggling to learn screen and tmux....byobu brought tears to my eyes

          – HDave
          Sep 23 '14 at 21:06











        • disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

          – mimoralea
          Nov 21 '17 at 20:49













        17












        17








        17







        You cannot do this once the process has started, you need to have set things up before you run a long running job.



        You can use nohup but modern wisdom suggests you use screen or byobu as your login so you can detach and leave things running.



        Screen has the advantage that you can detach from one machine and reattach from another which is handy if you want to check on long running processes that run beyond the end of the working day.



        There is a reasonable getting started guide to screen here.



        byobu puts an easy to use interface on top of screen with menus etc. It's also the current implementation of screen on newer ubuntu. F2 to start a new terminal F3/F4 to toggle back and forth and F6 to disconnect. Type exit to actually end terminals permanently.






        share|improve this answer















        You cannot do this once the process has started, you need to have set things up before you run a long running job.



        You can use nohup but modern wisdom suggests you use screen or byobu as your login so you can detach and leave things running.



        Screen has the advantage that you can detach from one machine and reattach from another which is handy if you want to check on long running processes that run beyond the end of the working day.



        There is a reasonable getting started guide to screen here.



        byobu puts an easy to use interface on top of screen with menus etc. It's also the current implementation of screen on newer ubuntu. F2 to start a new terminal F3/F4 to toggle back and forth and F6 to disconnect. Type exit to actually end terminals permanently.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 23 '12 at 7:07









        wildintellect

        21316




        21316










        answered Oct 21 '10 at 12:16









        Richard HollowayRichard Holloway

        21.1k54252




        21.1k54252












        • byobu uses tmux these days..

          – scottl
          Nov 28 '12 at 7:04






        • 12





          "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

          – Rich
          May 23 '13 at 16:11











        • after struggling to learn screen and tmux....byobu brought tears to my eyes

          – HDave
          Sep 23 '14 at 21:06











        • disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

          – mimoralea
          Nov 21 '17 at 20:49

















        • byobu uses tmux these days..

          – scottl
          Nov 28 '12 at 7:04






        • 12





          "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

          – Rich
          May 23 '13 at 16:11











        • after struggling to learn screen and tmux....byobu brought tears to my eyes

          – HDave
          Sep 23 '14 at 21:06











        • disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

          – mimoralea
          Nov 21 '17 at 20:49
















        byobu uses tmux these days..

        – scottl
        Nov 28 '12 at 7:04





        byobu uses tmux these days..

        – scottl
        Nov 28 '12 at 7:04




        12




        12





        "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

        – Rich
        May 23 '13 at 16:11





        "You cannot do this once the process has started, you need to have set things up before you run a long running job." -- no, you can use disown to achieve this. See @bassgey's answer

        – Rich
        May 23 '13 at 16:11













        after struggling to learn screen and tmux....byobu brought tears to my eyes

        – HDave
        Sep 23 '14 at 21:06





        after struggling to learn screen and tmux....byobu brought tears to my eyes

        – HDave
        Sep 23 '14 at 21:06













        disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

        – mimoralea
        Nov 21 '17 at 20:49





        disown and if needed just Ctrl-z, then bg to get it of the active terminal and to the background. Then, disown.

        – mimoralea
        Nov 21 '17 at 20:49











        8














        Hey, while I agreed that screen is the most efective option.
        You can use vncserver and then start the process on it.



        Also if your only interes is to have the process running and no need to take control back of it, and utterly most important you were not aware you will need to close the session and you have the process already running, you are not of luck if you used bash as the shell



        First you need to send the process to background by typing Ctrl+Z followed by bg %1 (the number depends on the job number, usually it is 1, but you can easily pull the list using the command jobs)



        Finally invoke the command disown (followed by the jobid ... same as with bg command)



        This will remove the parent-child relationship between your shell and the process in background, preventing it to die when your shell is terminated.






        share|improve this answer


















        • 2





          This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

          – jwbensley
          Aug 10 '12 at 17:13







        • 1





          Simply bg (without %1) is often enough, since the default is the current job

          – Walter Tross
          Nov 23 '12 at 21:55











        • It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

          – Krazy Glew
          Jul 12 '18 at 23:02
















        8














        Hey, while I agreed that screen is the most efective option.
        You can use vncserver and then start the process on it.



        Also if your only interes is to have the process running and no need to take control back of it, and utterly most important you were not aware you will need to close the session and you have the process already running, you are not of luck if you used bash as the shell



        First you need to send the process to background by typing Ctrl+Z followed by bg %1 (the number depends on the job number, usually it is 1, but you can easily pull the list using the command jobs)



        Finally invoke the command disown (followed by the jobid ... same as with bg command)



        This will remove the parent-child relationship between your shell and the process in background, preventing it to die when your shell is terminated.






        share|improve this answer


















        • 2





          This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

          – jwbensley
          Aug 10 '12 at 17:13







        • 1





          Simply bg (without %1) is often enough, since the default is the current job

          – Walter Tross
          Nov 23 '12 at 21:55











        • It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

          – Krazy Glew
          Jul 12 '18 at 23:02














        8












        8








        8







        Hey, while I agreed that screen is the most efective option.
        You can use vncserver and then start the process on it.



        Also if your only interes is to have the process running and no need to take control back of it, and utterly most important you were not aware you will need to close the session and you have the process already running, you are not of luck if you used bash as the shell



        First you need to send the process to background by typing Ctrl+Z followed by bg %1 (the number depends on the job number, usually it is 1, but you can easily pull the list using the command jobs)



        Finally invoke the command disown (followed by the jobid ... same as with bg command)



        This will remove the parent-child relationship between your shell and the process in background, preventing it to die when your shell is terminated.






        share|improve this answer













        Hey, while I agreed that screen is the most efective option.
        You can use vncserver and then start the process on it.



        Also if your only interes is to have the process running and no need to take control back of it, and utterly most important you were not aware you will need to close the session and you have the process already running, you are not of luck if you used bash as the shell



        First you need to send the process to background by typing Ctrl+Z followed by bg %1 (the number depends on the job number, usually it is 1, but you can easily pull the list using the command jobs)



        Finally invoke the command disown (followed by the jobid ... same as with bg command)



        This will remove the parent-child relationship between your shell and the process in background, preventing it to die when your shell is terminated.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 6 '11 at 21:29









        Jorge GutierrezJorge Gutierrez

        8911




        8911







        • 2





          This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

          – jwbensley
          Aug 10 '12 at 17:13







        • 1





          Simply bg (without %1) is often enough, since the default is the current job

          – Walter Tross
          Nov 23 '12 at 21:55











        • It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

          – Krazy Glew
          Jul 12 '18 at 23:02













        • 2





          This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

          – jwbensley
          Aug 10 '12 at 17:13







        • 1





          Simply bg (without %1) is often enough, since the default is the current job

          – Walter Tross
          Nov 23 '12 at 21:55











        • It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

          – Krazy Glew
          Jul 12 '18 at 23:02








        2




        2





        This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

        – jwbensley
        Aug 10 '12 at 17:13






        This answer is the best! Why is everyone talking about screen, the question was posed post-login event, how to keep the processes running, now after logging in but before starting them. Great answer Jorge, you've really helped me! :)

        – jwbensley
        Aug 10 '12 at 17:13





        1




        1





        Simply bg (without %1) is often enough, since the default is the current job

        – Walter Tross
        Nov 23 '12 at 21:55





        Simply bg (without %1) is often enough, since the default is the current job

        – Walter Tross
        Nov 23 '12 at 21:55













        It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

        – Krazy Glew
        Jul 12 '18 at 23:02






        It would be nice to have a comprehensive answer: A priori (setting up in advance): ascii terminal screen (old), tmux (neewer); X windows: vnc (old, still maintained), xpra (newer), with xpra being rootless. A posterior (persisting after you started): ^Z, disown, ... But I am too lazy to flesh it out more than this.

        – Krazy Glew
        Jul 12 '18 at 23:02












        8














        For a single shell script that I have running over a long period of time, I will login, and run the process in the background using '&'.



        Example:



        /path/to/my/script &


        I've logged out and disconnected my SSH session. When I log in some time later, the script is still executing as proven by continuous data collection from the script.






        share|improve this answer


















        • 3





          Yes, I would like to know how screen / tmux is better than this simple solution.

          – Mads Skjern
          Mar 16 '15 at 8:51











        • Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

          – Daniel Pinyol
          Apr 22 '16 at 13:08






        • 1





          @MadsSkjern Because you can't enter any input into the script using this method.

          – Ken Sharp
          Feb 10 '17 at 22:18






        • 1





          @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

          – DarkCygnus
          Aug 24 '17 at 16:20















        8














        For a single shell script that I have running over a long period of time, I will login, and run the process in the background using '&'.



        Example:



        /path/to/my/script &


        I've logged out and disconnected my SSH session. When I log in some time later, the script is still executing as proven by continuous data collection from the script.






        share|improve this answer


















        • 3





          Yes, I would like to know how screen / tmux is better than this simple solution.

          – Mads Skjern
          Mar 16 '15 at 8:51











        • Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

          – Daniel Pinyol
          Apr 22 '16 at 13:08






        • 1





          @MadsSkjern Because you can't enter any input into the script using this method.

          – Ken Sharp
          Feb 10 '17 at 22:18






        • 1





          @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

          – DarkCygnus
          Aug 24 '17 at 16:20













        8












        8








        8







        For a single shell script that I have running over a long period of time, I will login, and run the process in the background using '&'.



        Example:



        /path/to/my/script &


        I've logged out and disconnected my SSH session. When I log in some time later, the script is still executing as proven by continuous data collection from the script.






        share|improve this answer













        For a single shell script that I have running over a long period of time, I will login, and run the process in the background using '&'.



        Example:



        /path/to/my/script &


        I've logged out and disconnected my SSH session. When I log in some time later, the script is still executing as proven by continuous data collection from the script.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 29 '14 at 14:58







        user108430














        • 3





          Yes, I would like to know how screen / tmux is better than this simple solution.

          – Mads Skjern
          Mar 16 '15 at 8:51











        • Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

          – Daniel Pinyol
          Apr 22 '16 at 13:08






        • 1





          @MadsSkjern Because you can't enter any input into the script using this method.

          – Ken Sharp
          Feb 10 '17 at 22:18






        • 1





          @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

          – DarkCygnus
          Aug 24 '17 at 16:20












        • 3





          Yes, I would like to know how screen / tmux is better than this simple solution.

          – Mads Skjern
          Mar 16 '15 at 8:51











        • Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

          – Daniel Pinyol
          Apr 22 '16 at 13:08






        • 1





          @MadsSkjern Because you can't enter any input into the script using this method.

          – Ken Sharp
          Feb 10 '17 at 22:18






        • 1





          @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

          – DarkCygnus
          Aug 24 '17 at 16:20







        3




        3





        Yes, I would like to know how screen / tmux is better than this simple solution.

        – Mads Skjern
        Mar 16 '15 at 8:51





        Yes, I would like to know how screen / tmux is better than this simple solution.

        – Mads Skjern
        Mar 16 '15 at 8:51













        Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

        – Daniel Pinyol
        Apr 22 '16 at 13:08





        Yes, I can see this on my ubuntu also, but it should not happen in theory. I don't understand why

        – Daniel Pinyol
        Apr 22 '16 at 13:08




        1




        1





        @MadsSkjern Because you can't enter any input into the script using this method.

        – Ken Sharp
        Feb 10 '17 at 22:18





        @MadsSkjern Because you can't enter any input into the script using this method.

        – Ken Sharp
        Feb 10 '17 at 22:18




        1




        1





        @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

        – DarkCygnus
        Aug 24 '17 at 16:20





        @MadsSkjern the reason is that if you run processes like this with & if you log out and in to your SSH session, the process will still be running however you will not be able to see the outputof that process (if your script echoed something you won't see it, but if it writes a file the file will be there)

        – DarkCygnus
        Aug 24 '17 at 16:20











        4














        You should check out GNU Screen and see if it helps you. Depending on how you need you application to run in realtime, it may cause more issues than it solves, but at least it will allow you to resume your session as if you never left it.



        How to use :



        • Use the command screen for the first start, scroll through the introduction messages, you should be handed a terminal.

        • C-a C-c opens another terminal

        • C-a C-k kills a terminal

        • You can use C-a C-Space and C-a C-Backspace to cycle through terminals

        • C-a C-a is handy if you're mostly using only two terminals

        • C-a C-d detachs the current screen session and exits screens. You can then use screen -r to resume that session. You can have several detached screen sessions at once, in this case you'll be displayed a list of available sessions.

        There are many other options, for example split screens, and also all shortcuts are fully customizable.






        share|improve this answer



























          4














          You should check out GNU Screen and see if it helps you. Depending on how you need you application to run in realtime, it may cause more issues than it solves, but at least it will allow you to resume your session as if you never left it.



          How to use :



          • Use the command screen for the first start, scroll through the introduction messages, you should be handed a terminal.

          • C-a C-c opens another terminal

          • C-a C-k kills a terminal

          • You can use C-a C-Space and C-a C-Backspace to cycle through terminals

          • C-a C-a is handy if you're mostly using only two terminals

          • C-a C-d detachs the current screen session and exits screens. You can then use screen -r to resume that session. You can have several detached screen sessions at once, in this case you'll be displayed a list of available sessions.

          There are many other options, for example split screens, and also all shortcuts are fully customizable.






          share|improve this answer

























            4












            4








            4







            You should check out GNU Screen and see if it helps you. Depending on how you need you application to run in realtime, it may cause more issues than it solves, but at least it will allow you to resume your session as if you never left it.



            How to use :



            • Use the command screen for the first start, scroll through the introduction messages, you should be handed a terminal.

            • C-a C-c opens another terminal

            • C-a C-k kills a terminal

            • You can use C-a C-Space and C-a C-Backspace to cycle through terminals

            • C-a C-a is handy if you're mostly using only two terminals

            • C-a C-d detachs the current screen session and exits screens. You can then use screen -r to resume that session. You can have several detached screen sessions at once, in this case you'll be displayed a list of available sessions.

            There are many other options, for example split screens, and also all shortcuts are fully customizable.






            share|improve this answer













            You should check out GNU Screen and see if it helps you. Depending on how you need you application to run in realtime, it may cause more issues than it solves, but at least it will allow you to resume your session as if you never left it.



            How to use :



            • Use the command screen for the first start, scroll through the introduction messages, you should be handed a terminal.

            • C-a C-c opens another terminal

            • C-a C-k kills a terminal

            • You can use C-a C-Space and C-a C-Backspace to cycle through terminals

            • C-a C-a is handy if you're mostly using only two terminals

            • C-a C-d detachs the current screen session and exits screens. You can then use screen -r to resume that session. You can have several detached screen sessions at once, in this case you'll be displayed a list of available sessions.

            There are many other options, for example split screens, and also all shortcuts are fully customizable.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 22 '12 at 15:31









            T. VerronT. Verron

            216210




            216210





















                3














                Simplest answer...



                ctrl+z will suspend the running program



                "bg" will run it in the background






                share|improve this answer


















                • 5





                  Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                  – Eliah Kagan
                  Aug 13 '13 at 0:32






                • 3





                  On my Ubuntu server, with default setup, it really does keep running!

                  – Mads Skjern
                  Mar 16 '15 at 8:53















                3














                Simplest answer...



                ctrl+z will suspend the running program



                "bg" will run it in the background






                share|improve this answer


















                • 5





                  Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                  – Eliah Kagan
                  Aug 13 '13 at 0:32






                • 3





                  On my Ubuntu server, with default setup, it really does keep running!

                  – Mads Skjern
                  Mar 16 '15 at 8:53













                3












                3








                3







                Simplest answer...



                ctrl+z will suspend the running program



                "bg" will run it in the background






                share|improve this answer













                Simplest answer...



                ctrl+z will suspend the running program



                "bg" will run it in the background







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 13 '13 at 0:28









                RoopRoop

                411




                411







                • 5





                  Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                  – Eliah Kagan
                  Aug 13 '13 at 0:32






                • 3





                  On my Ubuntu server, with default setup, it really does keep running!

                  – Mads Skjern
                  Mar 16 '15 at 8:53












                • 5





                  Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                  – Eliah Kagan
                  Aug 13 '13 at 0:32






                • 3





                  On my Ubuntu server, with default setup, it really does keep running!

                  – Mads Skjern
                  Mar 16 '15 at 8:53







                5




                5





                Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                – Eliah Kagan
                Aug 13 '13 at 0:32





                Without disowning the process (with something like disown or nohup), this will not usually keep the process running after the end of the SSH session.

                – Eliah Kagan
                Aug 13 '13 at 0:32




                3




                3





                On my Ubuntu server, with default setup, it really does keep running!

                – Mads Skjern
                Mar 16 '15 at 8:53





                On my Ubuntu server, with default setup, it really does keep running!

                – Mads Skjern
                Mar 16 '15 at 8:53











                3














                The easiest way is to run your command in the background with &. Then just write:



                disown -a





                share|improve this answer





























                  3














                  The easiest way is to run your command in the background with &. Then just write:



                  disown -a





                  share|improve this answer



























                    3












                    3








                    3







                    The easiest way is to run your command in the background with &. Then just write:



                    disown -a





                    share|improve this answer















                    The easiest way is to run your command in the background with &. Then just write:



                    disown -a






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jan 11 '17 at 18:09









                    Eliah Kagan

                    83.3k22229369




                    83.3k22229369










                    answered Jan 11 '17 at 3:52









                    ZibriZibri

                    24327




                    24327





















                        0














                        While everyone says to use disown (the only option you have after you already started the process), nohup, or even running the command in screen, which is useful if you want to see all the output from the command... I'm a fan of screen.. I still have tried most recent mainstream distributions of Linux and simply putting the job in the background and quitting does not cause all the processes that are running to die. There must be a global setting or something. I'm trying this on some pretty old systems (slackware 12) and my test script keeps running until I manually kill it:



                        shell$ cat > test.pl

                        #!/usr/bin/perl
                        while(1)
                        sleep(1);

                        shell$ perl ./test.pl &
                        shell$ exit
                        logout
                        shell$ ps aux test.pl
                        mymom 31337 1 0 13:25 ? 00:00:00 perl ./test.pl
                        shell$


                        While I agree that screen would be the best way to run this, even if my script wrote to log files or whatever.. I've never needed to use disown -a or nohup unless it was out of complete paranoia. Maybe someone can shed some light on how bash behaves by default? Maybe some system administrators change the defaults on large shells to keep their users' processes from overloading the system?






                        share|improve this answer

























                        • If you have any further query please ask it as a new question

                          – heemayl
                          Jul 30 '15 at 2:05















                        0














                        While everyone says to use disown (the only option you have after you already started the process), nohup, or even running the command in screen, which is useful if you want to see all the output from the command... I'm a fan of screen.. I still have tried most recent mainstream distributions of Linux and simply putting the job in the background and quitting does not cause all the processes that are running to die. There must be a global setting or something. I'm trying this on some pretty old systems (slackware 12) and my test script keeps running until I manually kill it:



                        shell$ cat > test.pl

                        #!/usr/bin/perl
                        while(1)
                        sleep(1);

                        shell$ perl ./test.pl &
                        shell$ exit
                        logout
                        shell$ ps aux test.pl
                        mymom 31337 1 0 13:25 ? 00:00:00 perl ./test.pl
                        shell$


                        While I agree that screen would be the best way to run this, even if my script wrote to log files or whatever.. I've never needed to use disown -a or nohup unless it was out of complete paranoia. Maybe someone can shed some light on how bash behaves by default? Maybe some system administrators change the defaults on large shells to keep their users' processes from overloading the system?






                        share|improve this answer

























                        • If you have any further query please ask it as a new question

                          – heemayl
                          Jul 30 '15 at 2:05













                        0












                        0








                        0







                        While everyone says to use disown (the only option you have after you already started the process), nohup, or even running the command in screen, which is useful if you want to see all the output from the command... I'm a fan of screen.. I still have tried most recent mainstream distributions of Linux and simply putting the job in the background and quitting does not cause all the processes that are running to die. There must be a global setting or something. I'm trying this on some pretty old systems (slackware 12) and my test script keeps running until I manually kill it:



                        shell$ cat > test.pl

                        #!/usr/bin/perl
                        while(1)
                        sleep(1);

                        shell$ perl ./test.pl &
                        shell$ exit
                        logout
                        shell$ ps aux test.pl
                        mymom 31337 1 0 13:25 ? 00:00:00 perl ./test.pl
                        shell$


                        While I agree that screen would be the best way to run this, even if my script wrote to log files or whatever.. I've never needed to use disown -a or nohup unless it was out of complete paranoia. Maybe someone can shed some light on how bash behaves by default? Maybe some system administrators change the defaults on large shells to keep their users' processes from overloading the system?






                        share|improve this answer















                        While everyone says to use disown (the only option you have after you already started the process), nohup, or even running the command in screen, which is useful if you want to see all the output from the command... I'm a fan of screen.. I still have tried most recent mainstream distributions of Linux and simply putting the job in the background and quitting does not cause all the processes that are running to die. There must be a global setting or something. I'm trying this on some pretty old systems (slackware 12) and my test script keeps running until I manually kill it:



                        shell$ cat > test.pl

                        #!/usr/bin/perl
                        while(1)
                        sleep(1);

                        shell$ perl ./test.pl &
                        shell$ exit
                        logout
                        shell$ ps aux test.pl
                        mymom 31337 1 0 13:25 ? 00:00:00 perl ./test.pl
                        shell$


                        While I agree that screen would be the best way to run this, even if my script wrote to log files or whatever.. I've never needed to use disown -a or nohup unless it was out of complete paranoia. Maybe someone can shed some light on how bash behaves by default? Maybe some system administrators change the defaults on large shells to keep their users' processes from overloading the system?







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jul 30 '15 at 2:04









                        heemayl

                        68.2k11144215




                        68.2k11144215










                        answered Jul 29 '15 at 17:42









                        Dan GullageDan Gullage

                        1




                        1












                        • If you have any further query please ask it as a new question

                          – heemayl
                          Jul 30 '15 at 2:05

















                        • If you have any further query please ask it as a new question

                          – heemayl
                          Jul 30 '15 at 2:05
















                        If you have any further query please ask it as a new question

                        – heemayl
                        Jul 30 '15 at 2:05





                        If you have any further query please ask it as a new question

                        – heemayl
                        Jul 30 '15 at 2:05











                        -1














                        Instead of :



                        cmd options; 


                        Add before nohup :



                        nohup cmd options & 


                        Then, you will be able to see the console stdout by :



                        tail -f nohup.out





                        share|improve this answer



























                          -1














                          Instead of :



                          cmd options; 


                          Add before nohup :



                          nohup cmd options & 


                          Then, you will be able to see the console stdout by :



                          tail -f nohup.out





                          share|improve this answer

























                            -1












                            -1








                            -1







                            Instead of :



                            cmd options; 


                            Add before nohup :



                            nohup cmd options & 


                            Then, you will be able to see the console stdout by :



                            tail -f nohup.out





                            share|improve this answer













                            Instead of :



                            cmd options; 


                            Add before nohup :



                            nohup cmd options & 


                            Then, you will be able to see the console stdout by :



                            tail -f nohup.out






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Oct 22 '16 at 10:51









                            Abdennour TOUMIAbdennour TOUMI

                            5,31343546




                            5,31343546















                                protected by heemayl Sep 16 '15 at 20:52



                                Thank you for your interest in this question.
                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                Would you like to answer one of these unanswered questions instead?



                                Popular posts from this blog

                                Tamil (spriik) Luke uk diar | Nawigatjuun

                                Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?