putting a backgroung job on ubuntu on ec2 which will work forever

0

I want to put a job on amazon ec2 which is something like delayed job for rails server. The job has to run even when my local machine get disconnected from ec2. Is there any way I can do that. I try screen but the job gets destroyed after sometime when I disconnect from amazon ec2. Any guesses.

Deepender Singla

Posted 2013-12-19T14:19:09.187

Reputation: 101

Answers

1

use nohup or run from a start up script.

Screen should work and if it doesnt there program exit'ed by itself check its logs

to use screen do

screen -S screen

[YOUR COMMANDS HERE] ctrl+a then d

To re attach

screen -r screen

when you re attach there should be some error message on the screen if the program exited unexpectedly

exussum

Posted 2013-12-19T14:19:09.187

Reputation: 431

Is there any specific way to use screen, I used it may be I used it in some wrong way. can you be bit elaborate on using screen. Initially I used nohup but I don't know why some days after is stops. – Deepender Singla – 2013-12-19T14:28:48.390

I run the command it was working till sometime but when I logout from the ec2, the command stops working as this command basically send email. When I login to the system -- and did screen -r screen, it actually shows this : 5683.screen (12/19/2013 02:54:39 PM) (Detached) can you tell where I am wrong. – Deepender Singla – 2013-12-19T16:41:14.640

try screen -r 5683.screen – exussum – 2013-12-19T16:42:50.110

it is basically showing the email which it sent before, there is also one more thing coming when I do screen -r screen that is :Type "screen [-d] -r [pid.]tty.host" to resume one of them. – Deepender Singla – 2013-12-19T16:47:29.333

Which program is it ? It should have error logs – exussum – 2013-12-19T16:53:32.417

its not a program just a rake jobs:work command for heroku so it can run rails delayed job on ec2. – Deepender Singla – 2013-12-19T17:04:23.393