D
D
daminik002016-11-10 10:01:52
PHP
daminik00, 2016-11-10 10:01:52

How to process the response from the server every couple of seconds and do it in the background on the server?

I'm making a bot for VKontakte and I need to check incoming messages every second and respond to them, but you can't do this with a browser always on)
PS Don't think, this is not an ordinary bot toy, I have already passed this stage.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2016-11-10
@orlov0562

- create a file: bot.php with the content:

while (true) {
// тут твой код делает свои грязные делишки
sleep(1);
}

- connect to the server via ssh
- install screen: apt-get install screen
- start a new session: screen -a
- run the script: php bot.php
- disconnect from the session: Ctrl+A+D
- restore the session if necessary: ​​Ctrl+D
- if you need to end the script, in the restored session, just press Ctrl + C.
When you realize that this is no longer enough for you, google "php demons"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question