Multiple PHP processes (call php by php and having different PID)

243 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 3
  • Weekly Top Seller
creativestuff
says

Hi actually I am making a temporized newsletter system (so I have the DB set up to save all the data needed like the message emails and so on)

I have a cronjob (cron.php) which is called every minute, this cronjob (actually) accesses the DB get out the active sessions , creates the email and sends the email with phpmailer (5 every minute to be sure the server won’t get blacklisted) working fine…

..until I decide to use more SMTPs (having 30) to have 150 emails sent / minute (each smtp gets 5 mails)

since there are 150 calls for sending mails + DB accessing + script run-time I might get out of allowed php execution time so I decide to brake down the mail sending part into another file (mail.php which will be called by cron.php) so from the actual: 1 process sending 150 emails – I want to get to 30 processes make 5 emails each

I was thinking to call mail.php with cURL… but each cURL waits for its response (I search for silent cURL but haven’t found anything useful)

Solutions would be:

a) having 30 cronjobs + 30 php files… I don’t like it since I don’t wanna add cronjobs each time another smtp has to be added

b) php Sockets – send 30 socket message without w8ing for the response.. (I don’t know if it would make a different process)..

ANY IDEA ?!?

22 posts
  • Affiliate Level 1
  • Author Level 3
  • Collector Level 2
  • Exclusive Author
+1 more
r0ash
says

set_time_limit(0); will make sure, your script dont get time out.

However if you are running your scripts via cron, I dont see why they will get timeout.

243 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 3
  • Weekly Top Seller
creativestuff
says

well yeah… but what if the server rules limit the execution time to the default 30S… I would like a solution for the more distinct processes (it might be useful at other projects)

...in other words how can a php script execute (without the EXEC function cuz that’s vulnerable and usually disabled on the hosting servers) another php script without requesting any feedback from it…

...like when the bully kicks the little boy on the tricycle down from the hill … he know that the little boy will brake his everything… but he goes away cuz he don’t care when and how… :D

5441 posts
  • Author Level 11
  • Moderator
  • Winner
  • 6 Years of Membership
+20 more
dtbaker
Moderator
says
243 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Author Level 3
  • Weekly Top Seller
creativestuff
says

thx dtbaker this should do the trick (almost forgot about fork… it’s been a long time I last used it)

by
by
by
by
by
by