Jump to content

Recommended Posts

Hi all,

 

I have a system where I need to send thousands of small text files to a webserver - all day, every day using HTTP POST (cURL).

 

I have decided to take the load away from my database and store each XML document within a directory on the server - open file, http post file, delete file.  Read file, http post file, delete file....

 

I wish for this to happen constantly. 

 

I could use a php script - running an infinite loop to "get next file" - read, http post, delete.... but I have a gut feeling that this would be a bad idea because:

 

1) If a script is in an infinite loop - would there be a huge performance impact on the rest of the scripts running on the server?

2) If I close my web browser - the script will terminate?

 

So.. what is the best thing to do? 

 

a) Should I have a CRON job that calls the PHP script every minute (with a max execution time of say 55 seconds)?

b) Should I run the php script containing an infinite loop from the command line (which I understand will keep running because it has not been called by a client browser)?  if so, how would I terminate the script?

 

Do you guys have any other ideas?

 

Many thanks,

 

AM.

 

 

Link to comment
https://forums.phpfreaks.com/topic/88110-running-scripts-forever/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.