Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
As long as your script doesn't hang, it'll exit and release what little memory was allocated to it. So php-fpm may be allowed 2G but if your script only uses 14M it'll only use that much and then release it.
But I could be talking out of my arse. 🤷♀️ -
emyu105827yLet me explain the scenario.
I have 2 php scripts, a.php and b.php
a.php has an infinite while loop. Each iteration runs b.php and then sleeps for 5 seconds.
Then I run a.php on the terminal appending & in order to send it to the background.
So the while loop in a.php keeps running in the background and after sometime, the web server starts sending 503. -
@emyu10 Oh okay. I'm just guessing this here but I would say that every time a.php spawns b.php, it allocates memory but won't release it until the while loop is exited. So it builds until you run out.
Is b.php not something you can cron? -
@emyu10 Time to learn ;) But essentially your cron entry would look something like:
*/5 * * * * /usr/bin/php /path/to/b.php
You have to put the full path to your php executable because $PATH doesn't exist for cron jobs.
If in doubt: man crontab (: -
emyu105827y@scytheri0n yes obviously. It's right under my fingertips, yet I don't learn it.
@JKyll php because I don't manage the server. Not authorized to install anything. Plus I am only confident in php. Thought of using python for the job. But it's not installed.
BTW: b.php checks an online server for updates and 'act upon it'.
The server we are working on can't be accessed from outside. -
@emyu10 why would you need to check for updates every 5 seconds? try increasing the 5 seconds to 5mins or 5 hours even.
-
Just realized the cron line I gave you is for minutes. Because it's the end of the day and I don't ready properly.
Related Rants
Does, running a php script every 5 seconds as a background process, takes up the whole memory allocated for the process that runs php-fpm and stop serving to apache?
(I don't really know what I am talking about)
question
apache
php
php-fpm