Constantly running script

I want to create a script with a while(true) {…} in it. Within that there will be the if (thishappens) {…} or elseif…

The question I have is how do I make that start running. I know I could open a browser and go the the site, but once I close the browser, the *.php file will close as well.

I want to open the file with a browser (since my server is across country) and it will run forever, eventhough my browser is closed. How do I get a script to run after the browser has been closed?

Also if I enact something that makes this work (then I close the browser and walk away), how do I know it has worked without any visual confirmation?

Thank you

May I ask what you are trying to do… a continuously running loop can cause problems for your resources. You may want to look into a cron job or psuedo cron job to do what you want this loop to.

I want to divide the program so one part runs at times a,b, and c during the day. Then part two runs at d,e, and f. And secion three runs at g,h, and i. And so on. This will happen everyday. I thought why not have the program always run. The time it takes to test an if on a small program is very small so there will not be much wasted processing time for this issue. Is there a way that I can have a program automatically run section one at its approapriate time and section two…?

Can you explain the basics of Cron for me

Thanks

I admit that cron is not a strong point of mine (I use it to back up my Database every night at midnight.) but I can give you a basic idea of what it does.

Cron is a ‘program’ that allows you to ‘schedule’ certain programs to run. Now I have a few links for some info (caution it looks bad) but you will really have to do some of your own research. peg110 know alot more about cron then I do.

Links:
http://www.unixgeeks.org/security/newbi … ron-1.html
http://www.4webhelp.net/tutorials/misc/cron.php
http://www.htmlcenter.com/tutorials/tut … 5&type=PHP

The IF check is not much of a time waster but the WHILE IS. As was pointed out, this can (and probably will) cause a problem within your server. If you do not own the server, I am sure your Host will shut down such a script.

CRON is the best way to do it. The basics of a cron job are to schedule tasks. A cron entry has multiple parts (delimited by a SPACE).

The first 5 fields represent the time (Minute, Hour, Day, month, and Weekday) the last field is the command or script you want to run.

For more info you can do a google on cron, cron job, or crontab.

http://www.nerc-online.com/support/www/crontab.html

I have already setup my cron job for this and will alter the future script to run this way. Thank you for all your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service