Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I will be running some batch process on Amazon EC2 Ubuntu 12 machines. I can log in using putty, run the command. The process will run for a day or two. There is a chance the putty will get disconnected. However I need the program keep running on the remote Ubuntu machine. Is it possible?

Like Windows RDP, log in to a machine, start some app, disconnect, come back later, app is still running. Similar experience in Ubuntu, how can I get? Thank you.

Thanks/.

share|improve this question

closed as off-topic by kce, Jenny D, Ward, mdpc, Falcon Momot Feb 26 at 0:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – kce, Ward, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
If you are running telnet, you're in BIG trouble. Please use ssh! –  Deer Hunter Feb 22 at 5:55
    
@DeerHunter I don't believe it's possible to get into an EC2 instance with telnet, but i can't explain why the question includes it. –  Robbie Mckennie Feb 22 at 6:32
1  
why not install cron jobs on your 12 machines and let cron run your commands for you? –  Red Cricket Feb 22 at 6:39
    
@RedCricket That seems like an awfully roundabout way of just executing something in the background –  Robbie Mckennie Feb 22 at 7:03
1  
@Robbie how so? opening up putty or a windows C:\> and then executing putty then login in to 12 different boxes and running a command seem far more "roundabout" then have a simple cron job on each of the boxes. I guess to some people setting up a cronjob is difficult. To each his own I guess. –  Red Cricket Feb 22 at 7:18
show 2 more comments

2 Answers 2

Screen. You will probably need to install it with apt-get install screen or similar, but once you have it, it's quite straight forward. Use screen to start it, and you will be given a bash or sh shell, use that to run your batch job, then use Ctrl+A followed by Ctrl+D to detach from the session. You may then log out, and can reattach at any time using screen -r. See man screen for more information. You could also simply fork the job to the background with an ampersand, ./job.sh &, but you will not be able to reattach to it at some later point in time.

share|improve this answer
1  
Tmux is far more flexible than screen IMHO, but they both get the job done. –  quadruplebucky Feb 22 at 5:12
    
I'll have to check that out –  Robbie Mckennie Feb 22 at 5:14
    
By the way, Screen is already installed on the default Amazon EC2 AMI. They must realize it's useful ;) –  David Manheim Jun 18 at 4:59
add comment

use nohup and & with your command / batch process. RUn you script or command like below

  nohup command &

even your putty session disconnect your command will continue to run in background.

share|improve this answer
add comment

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