Jump to content

Recommended Posts

I'm using WAMPSERVER

 

The file that executes forever, will check the date, hour and minute from the system and send an automated message when date/hour/minute is the same criteria as the message itself.

 

I've got the time,date,hour, etc stuff already sorted, but how can I have the php script continuosly run?

 

Would it be possible to make Apache run it on start?

Link to comment
https://forums.phpfreaks.com/topic/110999-solved-make-a-php-file-execute-forever/
Share on other sites

I wouldn't do that if I were you....but whatever.  Put it in its own folder and use set_time_limit(0) and use a .htaccess to make Apache not timeout.  I really wouldn't do it like that if I were you though. O_O  Why do you need to do this, by the way?

you can use set_time_limit() to make the script never time out, and then run an infinite loop. but, it sounds like you just want something to run every hour? Am I right? If you are using Windows, just use the Scheduled Tasks to execute the script every hour

I'm using WAMPSERVER

 

The file that executes forever, will check the date, hour and minute from the system and send an automated message when date/hour/minute is the same criteria as the message itself.

 

I've got the time,date,hour, etc stuff already sorted, but how can I have the php script continuosly run?

 

Would it be possible to make Apache run it on start?

 

From what I am understanding, you might want to look into cronjobs if your server supports enables you to do such a thing.

 

Regards,

Ironphp

I'm using WAMPSERVER

 

The file that executes forever, will check the date, hour and minute from the system and send an automated message when date/hour/minute is the same criteria as the message itself.

 

I've got the time,date,hour, etc stuff already sorted, but how can I have the php script continuosly run?

 

Would it be possible to make Apache run it on start?

 

From what I am understanding, you might want to look into cronjobs if your server supports enables you to do such a thing.

 

Regards,

Ironphp

 

if it's wampserver, it should be Windows...aka use Scheduled Tasks

it won't run through the wampserver. it will be a PHP Command Line Interface (CLI) script. i assume wampserver installs the PHP executable, but not sure where exactly. once you find that executable, you can run scripts from the command line like so:

c:\path\to\php.exe -f c:\path\to\phpscript.php

and in your scheduled task, you would put the above command into the "Run" field

I Googled a bit and just found the answer...it's kind of weird, but it works:

 

1) Create a BAT file (I called mine run.bat) and put the line from before in it (here it is again):

c:\path\to\php.exe -f c:\path\to\phpscript.php

 

2) Right click on the new BAT file and do Create Shortcut. Rename the new shortcut file to run.lnk

 

4) Right click the shortcut file and do Properties. In the Run field, select Minimized.

 

5) Have your scheduled task execute that shortcut file.

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.