Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating tasks at set intervals 1

Status
Not open for further replies.

tobyheywood

IS-IT--Management
Apr 20, 2001
122
GB
Dear all,

I am in the process of developing a script to upload images to a web server (via FTP) from a PC running 1 or more web cams. FTP side of things sorted.

I'm now trying to work out the best angle to approach automating the uploading of images at a set interval.

My intended route so far...

1) Set cron job to run every minute of the day
2) PHP script will only execute image uploads between hours of 8am and 6pm.
3) PHP Script will upload images every 5 seconds...

Now, my thoughts were to use some sort of while loop (after adjusting maximum script execution time to 60 seconds) which would check to see if the second at execution was one of the following;

Code:
00, 05, 10, 15, 20, 25, 30, etc.

If the second at execution matched one of the above then it would perform an upload, if not then it wouldn't.

Could someone advise me on the most appropriate REGEX string which return true if a match was found?

No matter how many times I read documentation about REGEX it fries my brain. %-)

Thank you in advance.

Regards

Toby Heywood

 
not sure that you would want to use regex here. it's a pretty slow sledgehammer to crack a simple nut!

this would probably work faster (or you could use in_array or similar)

Code:
function testtime()
{
	$sec = date("s");
	return ($sec/5 === ceil($sec/5));
}

 
ArkM & JPadie,

Thank you for your responses.

I have chosen to use the code suggested by ArkM as it seems the most simplistic, yet it hit the nail dead centre on the head.

Thank you both again for your suggestions.

Regards


Toby Heywood

 
of course both code snips address the problem you posed the same way! i've never come across the modulus operator before but it's defitely one i'll add to my tool box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top