0

I got the 140dev Twitter framework (which uses the Twitter phirehose) manually running (via the webbrowser on my local wamp server), but I can't figure out how to run both get_tweets.php and parse_tweets.php as a background process like with SSH commands:

nohup php script.php > /dev/null &

Some of you started using (the Windows equivalent of) cronjobs, but this isn't the right way to go. I think this is because of creating multiple connection (or re-connections) to the Twitter streaming phirehose isn't allowed? How can I run both PHP scripts (get_tweets.php and parse_tweets.php) as a background process on my local WAMP server (and later on a VPS)?

Just to clearify:

  • I am using a WAMP server (first to test a little bit and later to run it on a VPS)
  • Using LAMP or any *nix server/system isn't an option (due to time, experience and lack of skills)
  • I have searched for solutions (on google and stackoverflow), but they are either not working or not clear enough for me (I am new to this)

Thank you in advance.

TRD07
  • 1
  • 3
  • How about running a PHP based windows service (net start/net stop etc...). From php.net doc: "The win32service extension is a Windows specific extension that allows PHP to communicate with the Service Control Manager to start, stop, register and unregister services, and even allows your PHP scripts to run as a service." http://docs.php.net/manual/en/intro.win32service.php – Cyril Tourist Jul 13 '12 at 11:35
  • @UgoMéda Méda: I used the following solutions: $com = new Com('WScript.shell'); $com->run('php yourscript.php', 0, false); as a .bat file and a .php file in combination with Freebyte task scheduler but this didn't work. I added the php path to environment variables to use ('php...). I also used other .bat files with the following code: '@ECHO OFF php -f script.php' or something like this. But this also didn't work. CyrilTourist: looks interesting I will have a look at it. Note: I am quite new to all this php and server stuff so that makes it hard. – TRD07 Jul 13 '12 at 12:34

1 Answers1

0

Find the php/bin folder where the php.exe is located. Copy the folder path and add it to your PATH environment variable (Follow this for instance to edit your PATH variable.

Once this is done, you'll be able to execute php in the command line from anywhere. Just start php script.php with a command line in the right folder and it should work. There might be some configuration to make so that the php in command line uses WAMP's php.ini.

Community
  • 1
  • 1
Ugo Méda
  • 1,205
  • 8
  • 23
  • "execute php in the command line from anywhere" This is probably my problem. I don't quite understand this part. Should I open cmd and navigate to the script.php folder to start it? Or do I have an alternative route/approach? And what about that last part "configuring php in command line to use WAMP's php.ini"? – TRD07 Jul 13 '12 at 13:20
  • Yes, open cmd in your script forlder and start it. You can create a bat to do it. – Ugo Méda Jul 13 '12 at 13:39
  • I opened cmd and "cd-ed" to the right folder. I then used php-win -f script.php to start the process and it worked! using the php -f script.php command didn't let me close the cmd box and php-win runs in the background. Final question is whether this also works on a VPS? Can I use remote desktop connection to start cmd and do exactly the same as with my wamp server? – TRD07 Jul 14 '12 at 12:36