S
S
sddvxd2017-05-01 14:49:29
linux
sddvxd, 2017-05-01 14:49:29

Starting and stopping scripts with a loop?

Good afternoon.
I have a script with an infinite loop. I can't just run it (I run it on hosting via ssh) because as soon as I close the console, the script exits. I solved this problem using cron, everything works fine.
Now I encountered such a problem - in order to leave this script, I will have to kill the php process, and not 1 script with a cycle is running there, I have to raise all the scripts again through cron, which is very inconvenient and I have to run 10 files from 1 line again. Maybe there are some ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2017-05-01
@sddvxd

  1. In order for the script to continue executing after disconnecting from the console, it must be run in the background via nohup. For example like this:nohup php ./myscript.php &
  2. Using the PHP function getmypid, get the process id, save it to a pid file, and kill only that process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question