TJMAudio Posted October 10, 2006 Share Posted October 10, 2006 Hi everyone,I would like to make a function that lasts 30 minutes, then adds a set amount to a variable, then starts the countdown over again. How would I make this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/23507-recurring-countdown-that-adds-to-a-variable/ Share on other sites More sharing options...
matte Posted October 10, 2006 Share Posted October 10, 2006 if you are wanting the program to run every 30 minutes i would use crontab on linux machine or task scheduler on windows machine Quote Link to comment https://forums.phpfreaks.com/topic/23507-recurring-countdown-that-adds-to-a-variable/#findComment-106661 Share on other sites More sharing options...
TJMAudio Posted October 10, 2006 Author Share Posted October 10, 2006 What?I just want part of my script to execute every 30 minutes, not a program. Quote Link to comment https://forums.phpfreaks.com/topic/23507-recurring-countdown-that-adds-to-a-variable/#findComment-106663 Share on other sites More sharing options...
btherl Posted October 10, 2006 Share Posted October 10, 2006 The sleep() function will wait a specific number of seconds. It is usually accurate to within a second, but it may wait longer, particularly if the system is under load. If you need EXACTLY 30 minutes, then that's more difficult. If you want approximately 30 minutes, then sleep(60 * 30) will work.Another option is to check time() regularly, and see when 30 minutes have passed. You can use sleep(1) in a loop to ensure that you only check the time once a second. Quote Link to comment https://forums.phpfreaks.com/topic/23507-recurring-countdown-that-adds-to-a-variable/#findComment-106664 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.