Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue May 01, 2012 3:49 pm 
Offline
Senior Newbie

Joined: Tue May 01, 2012 3:31 pm
Posts: 5
All,

I am relatively new to this. I am trying to run a PHP process in the background but as soon as I launch the process it stops. Here is the basic command:

php script.php &

The idea is to leave this script running all day, even after I logout, in which case it seems like I will go with something like this:

nohup php script.php &

I am on Ubuntu and the script is opening a stream to the Twitter Streaming API.

Any ideas or suggestions would be appreciated. Thanks!

-et


Top
   
 Post subject:
PostPosted: Tue May 01, 2012 4:39 pm 
Offline
Junior Member

Joined: Sat Feb 18, 2012 12:26 pm
Posts: 24
If the script is run without putting it the background does it hold on to the shell and work?

php script.php

Any logging in to to see if it's erroring or terminating naturally?


Top
   
 Post subject:
PostPosted: Tue May 01, 2012 5:12 pm 
Offline
Senior Newbie

Joined: Tue May 01, 2012 3:31 pm
Posts: 5
Yes, it runs just fine in the foreground.


Top
   
 Post subject:
PostPosted: Tue May 01, 2012 5:34 pm 
Offline
Junior Member

Joined: Sat Feb 18, 2012 12:26 pm
Posts: 24
Try launching it this way:

nohup php -q /path/to/script.php < /dev/null &


Top
   
 Post subject:
PostPosted: Tue May 01, 2012 10:02 pm 
Offline
Senior Newbie

Joined: Tue May 01, 2012 3:31 pm
Posts: 5
Aha! That seems to work. At least it lets me run the script in the background while I am logged in. I don't think it stays running after I logout, so now I am going to figure out how to make that work.

Thanks so much,

-et


Top
   
 Post subject:
PostPosted: Tue May 01, 2012 10:12 pm 
Offline
Senior Newbie

Joined: Tue May 01, 2012 3:31 pm
Posts: 5
Ok, a little investigation revealed that it's indeed working exactly as I wanted - the process is running in the background and stays running even after I logout.

Excellent! Again, thanks for the help.

-et


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group