Results 1 to 16 of 16
  1. #1

    Keeping a program executed after leaving ssh session?

    How do I keep a file to keep running when I exit out of an ssh session so the program keeps running?

  2. #2
    Join Date
    Jul 2001
    Location
    Toronto, ON.
    Posts
    312
    just type "nohup <command to execute>"

    so, if i'm running a script called checkout.pl, and i want to it continue whether or not i log out or my connection drops or whatever, i'd type:

    > nohup checkout.pl

    cool?

  3. #3
    You could also do this:

    /path/to/command.sh &
    321Host-It Internet Services
    http://www.321host-it.com
    ICQ: 17021242 E-mail: [email protected]

  4. #4
    Join Date
    Sep 2000
    Posts
    389
    If the program requires the terminal access, it will stop execution. You can run screen to keep your processes running safely when you logout. It help also to keep your session intact if you get disconnected from the net for some reason.

  5. #5
    /path/command &

    is what I do.
    Jeremy [email protected]
    Front Drive Advanced multi-domain hosting solutions
    http://www.frontdrive.com/

  6. #6
    Join Date
    Jan 2002
    Posts
    574
    'man screen'

    screen works better (IMO) than just sending it into the background... since you can easily use 'screen -r' (especially useful for interactive programs)

  7. #7
    Join Date
    Nov 2001
    Location
    Glika Nera - Athens - Greece - Europe
    Posts
    2,295
    nohub indeed, that's the one

  8. #8
    Join Date
    Jun 2002
    Posts
    1,376
    nohup, not nohub. (Although hopefully you'll have all switches and no hubs... )

    I typically just append the "&" to run it in the background, but I'd guess that nohub/screen are probably "more correct"

  9. #9
    Join Date
    Nov 2001
    Posts
    1,262
    i use screen myself

  10. #10
    Join Date
    Jun 2002
    Location
    Silver Spring, Maryland
    Posts
    256
    If it's interactive use screen, but if it's not then just use & (as Gernot described it). There's no real point to using screen for a daemon.

  11. #11
    Join Date
    Apr 2002
    Location
    Cornfield
    Posts
    131
    Yes, but my understanding is, if you simply background a process with &, it's still attached to your terminal, and will be killed if your terminal disconnects, eg, network outage or similar. If it's something that absolutely has to be ran and not interuppted the first time, then I screen it. It's not that hard to de-attach/re-attach screens.
    Fire extinguisher extraordinare
    -------------------------------
    FastServers.Net NOC Admin

  12. #12
    Join Date
    Jul 2001
    Location
    Toronto, ON.
    Posts
    312
    ^^^ correct ... logging out kills existing & jobs.

  13. #13
    Join Date
    Jun 2002
    Location
    Silver Spring, Maryland
    Posts
    256
    That's pretty weird, I've heard & read that same thing many times. I've probably used & to run processes in the background hundreds of times by now, on many different servers (running different types of unix as well), and its worked every time Originally I tried to figure out what was going on, but then I thought "What the hell, if it works I'll use it."
    Last edited by no1v2; 08-27-2002 at 05:51 AM.

  14. #14
    Originally posted by MarlboroMan
    Yes, but my understanding is, if you simply background a process with &, it's still attached to your terminal, and will be killed if your terminal disconnects, eg, network outage or similar. If it's something that absolutely has to be ran and not interuppted the first time, then I screen it. It's not that hard to de-attach/re-attach screens.
    No, if you use & it's not attached to your terminal but you still get the output of this program. If you log out after running a command with &, that process still continues running until it's finished.
    & is my favorite because it's so simple to use and there's, in most cases, no need to take the complicated approach by using nohup
    321Host-It Internet Services
    http://www.321host-it.com
    ICQ: 17021242 E-mail: [email protected]

  15. #15
    Join Date
    Jun 2002
    Posts
    1,376
    I agree, I can start somethign with "&" and log out, and it keeps going. (Though forcibly killing the terminal closes it. Does bash come with a script or something that will move things to "screen" or "nohup"?)

  16. #16
    Join Date
    Jul 2002
    Location
    Philadelphia, PA
    Posts
    15
    nohup usage:
    nohup [command]

    Apparently, if you use the C-shell, before you logout.. just type "nohup" and it should save all the currently running processes of your shell. Shame that the C-shell is (otherwise) a horror to work with

    I recommend just using 'screen', run it when you login.. and forget about it. Screen has a bunch of other nice things like copy/paste, multiple virtual windows (full or split-screen modes), etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •