0

I'd like to create linux daemon (in php), it will run an internal timer to manage my php scripts. (ie.: frontend cache update, data pre processing etc. these are existing services, now we run each script in bash with "nohup")

So my question is, how can i create single thread for each started process? At all possible do it with php?

5
  • Possible duplicate of Multithreading in PHP Commented Dec 21, 2013 at 23:01
  • 2
    Get the OS to run the scripts (possibly on a cron), it will manage the number of threads and you will not have to worry about any of it. Also, PHP does not support threading. Commented Dec 21, 2013 at 23:01
  • if it must be done in php, look into php fork. pcntl_fork php.net/manual/en/function.pcntl-fork.php Commented Dec 21, 2013 at 23:04
  • i prefer to use an os independent manager layer. And also i need sql based event and queue management. (administrator can edit timing and piority of processing, change item positions in queue if need etc. ) Commented Dec 21, 2013 at 23:09
  • @JustinWood yes it does. Commented Dec 22, 2013 at 7:22

1 Answer 1

2

You can use pthreads extension for multithreading, but a cronjob for every script sounds more convenient for your case.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, its look good. But now i have another problem, maybe you can help me. When i try to install it: "No releases available for package "pecl.php.net/pthread""
I don't know what you tried but you can check the comments section here: php.net/manual/en/pthreads.installation.php Also note that extension requires ZTS enabled PHP. If it's not enabled in your version, you have to compile PHP with ZTS enabled option.

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.