Skip to main content
  1. About
  2. For Teams
Asked
Viewed 1k times
Part of PHP Collective
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
    recoup8063
    –  recoup8063
    2013-12-21 23:01:22 +00:00
    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.
    Justin Wood
    –  Justin Wood
    2013-12-21 23:01:29 +00:00
    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
    loushou
    –  loushou
    2013-12-21 23:04:14 +00:00
    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. )
    AttilaBalazs
    –  AttilaBalazs
    2013-12-21 23:09:11 +00:00
    Commented Dec 21, 2013 at 23:09
  • @JustinWood yes it does.
    Joe Watkins
    –  Joe Watkins
    2013-12-22 07:22:05 +00:00
    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

Post as a guest

Required, but never shown

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.