Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP background process

I've wrote a php irc bot, but i need it to work in the background. With this there'd be no quits or so. What is the best way to do this?

Thanks and Regards.

like image 533
jamall55 Avatar asked Aug 18 '10 18:08

jamall55


People also ask

How to run php in background?

You can put a task (such as command or script) in a background by appending a & at the end of the command line. The & operator puts command in the background and free up your terminal. The command which runs in background is called a job. You can type other command while background command is running.

How do I know if php script is running in background?

If you started it in background use ps aux | grep time. php to get PID. Then just kill PID . If process started in foreground, use to interrupt it.

How do I run a php script continuously?

Cron jobs are timed jobs that can for example execute a PHP script. You could set up a cron job to check which user should receive his/her sms every hour. Depending on your operating system you can set up these cron jobs. For linux distrubutions there are tons of guides on how to set this up.


1 Answers

Take a look at the following website. There is a pretty descend explanation on how to write PHP daemons.

http://kevin.vanzonneveld.net/techblog/article/create_daemons_in_php/

like image 137
Timo Haberkern Avatar answered Sep 24 '22 04:09

Timo Haberkern