0

I just get a debian vps server for the first time and even set it cost me I succeeded. Now I have an existential question, I want to make a php script running continuously, is to try iOS push notifications,? Can you tell me how this it?

I start my virtual console SSH and I run / usr/bin/php5 push.php and Apple connection, this perfect works but when I close the console and I open is no longer running, I guess that when you close the session executed everything stops. What do I do for that is always running that script?

And I guess to make sure you always running should create another script to control it to restart when stopped Or am I wrong?

Thanks for your help

2 Answers 2

2

Run the command with the ampersand (&) this makes it run in the background

/usr/bin/php5 push.php &
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks friend but when i rerun the SSH an enter my password an my user and I see the process with ps -aux this process not there
if you use the ampersand, the process is forked to the background but will still be closed when you quit the login shell.
Can you add the contents of push.php
then, That I can do to not close? Thanks
who is upvoting this?
0

there are a couple of ways to do this.

1) start a screen session, so that your session stays active even when your SSH connection terminates (this is useful if you have a long-running process you want to reconnect to later).

2) use the nohup command (this is the simplest solution, e.g. nohup /usr/bin/php5 push.php).

3) get your script running properly as a service (this is the proper way to do it. on debian you should look into using an init script, or similar).

if you plan on using this in the long run, you should look into option 3 :)

1 Comment

More thans I just try option two and it works perfect. I'm going to do now the third option because as you have told me is the best thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.