SSH/Putty/Bash Help. Command to keep a program running after i have logged out

Discussion in 'OT Technology' started by Scream_Phoenix, Jun 16, 2005.

  1. Scream_Phoenix

    Scream_Phoenix Handsome Boy Model

    Joined:
    May 31, 2001
    Messages:
    45,151
    Likes Received:
    172
    Location:
    Capital City
    when i log into my webspace ssh with putty, i can start up a program and it runs as long as i am logged in. is there an argument or command i can use that will allow the program to run after i have quit the session until i log back in and cancel it manually? the program i am trying to run is bittornado if that matters.

    tia :)
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    you're better off NOT posting what illigal activities you're trying to accomplish.
     
  3. Scream_Phoenix

    Scream_Phoenix Handsome Boy Model

    Joined:
    May 31, 2001
    Messages:
    45,151
    Likes Received:
    172
    Location:
    Capital City
    what did i ask that was illegal? :confused:
     
  4. Rob

    Rob OT Supporter

    Joined:
    Jul 6, 2002
    Messages:
    88,625
    Likes Received:
    40
    Location:
    Atlanta, GA
    The best way to do it is install "screen". http://www.gnu.org/software/screen/

    Then do something like this:

    screen ./btdownloadcurses.py debian-31r0a-i386-binary-1.iso.torrent

    Once it is running hit Ctrl+A+D to detach the window. You will be dropped back at the shell while your program is still running.

    screen -r

    will reattach the window. Or if you have multiple screens deatched screen -r will list the PIDs of all the running screens. Then you can do

    screen -r pid

    To reattach the specific one you want.
     
  5. Rob

    Rob OT Supporter

    Joined:
    Jul 6, 2002
    Messages:
    88,625
    Likes Received:
    40
    Location:
    Atlanta, GA
    Or you could do it the ghetto way and add a "&" to the end to background the process then kill -9 it when you "think" the torrent is done. :o
     
  6. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    well, since & is a built-in that's how i would do it :dunno:
     
  7. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,454
    Likes Received:
    12
    Incorrect.

    '&' although puts the job into the background, the job will die once you log out of your shell. Usually if the parent (shell) dies, the children (processes) die.

    You need to nohup that process. Just tag nohup before your command and redirect the output to whereever if you want it. By default it puts it in ./nohup.out

    nohup /the/command/you/want/to/run > /dev/null 2>&1 &

    If you forget to put your command in the background, '&', just type in "Ctrl + Z", and then bg, to stop your job and then put it in the background.
     
  8. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    beat me to it
     
  9. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,454
    Likes Received:
    12
    I've setup a perl macro that automatically calls and pages me when a UNIX/Linux question is asked on all the boards I frequent.
     
  10. Supernaut

    Supernaut New Member

    Joined:
    May 20, 2003
    Messages:
    8,047
    Likes Received:
    0
    rm torrent.log
    echo "" > torrent.log
    python btlaunchmany.py torrents/ > torrent.log &
    tail -f torrent.log

    Then Ctrl-C to kill the tail and BT continues running. You can check on the torrent's progress with tail -f torrent.log. If you leave BT running for a long time, consider using echo "" > torrent.log every couple of days or so to clear the log, it can grow quite large.
     
  11. Rob

    Rob OT Supporter

    Joined:
    Jul 6, 2002
    Messages:
    88,625
    Likes Received:
    40
    Location:
    Atlanta, GA
    I forgot that background processes are killed when you log out.

    You could always just use screen. :o
     
  12. cmsurfer

    cmsurfer ºllllllº

    Joined:
    Jun 6, 2003
    Messages:
    5,079
    Likes Received:
    0
    Location:
    NJ
    Show us some proof that the program bittornado is illegal...

    He asked a simple question and last time I checked, asking a question here is not illegal.

    How in the hell do you know what he is doing with it? You can't always assume that everything everyone does here is illegal.
     
  13. m2e

    m2e OT Supporter

    Joined:
    Aug 9, 2004
    Messages:
    48,119
    Likes Received:
    53
    Location:
    US
    what i did with ventrilo to keep it running after i logged out of my shell was

    ./ventrilo_srv -d

    and it ran till i reset my server

    :dunno:
     
  14. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,454
    Likes Received:
    12
    That is a function of the ventrilo, which is not built into all apps to put itself into a daemon-like mode.
     
  15. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    figured ;) There are some of you who are just too quick. Skinjob seems to be all over the C questions, 5gen_prelude is all over access q's and queries in general. whores :big grin:
     
  16. col_panic

    col_panic calm like a bomb Moderator

    Joined:
    Sep 19, 2003
    Messages:
    188,160
    Likes Received:
    0
    Location:
    winter haven, fl
    oh yeah :uh:
     
  17. crontab

    crontab (uid = 0)

    Joined:
    Nov 14, 2000
    Messages:
    23,454
    Likes Received:
    12
    I'm kidding of course. I just follow a routine on what websites/email I check out when I get to work...
     
  18. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Exactly what I was about to post :)
     
  19. ledzep73

    ledzep73 New Member

    Joined:
    Feb 28, 2005
    Messages:
    6,868
    Likes Received:
    0
    Location:
    Louisville
    Screen is nice, I used to run nAIM on a screen all the time, and I was logged on for like 60 days or something.
     
  20. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    yea, i figured you didn't take ot THAT seriously
     
  21. Scream_Phoenix

    Scream_Phoenix Handsome Boy Model

    Joined:
    May 31, 2001
    Messages:
    45,151
    Likes Received:
    172
    Location:
    Capital City
    thanks a lot for the replies, screen is exactly what i was looking for. i was told to use it once before but i couldnt remember what it was. i even tried typing "screen" but it didnt work, i didnt realize it had to be installed :cool:
     

Share This Page