Jump to content


Photo

Recurring Countdown that adds to a variable?


  • Please log in to reply
3 replies to this topic

#1 TJMAudio

TJMAudio
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 10 October 2006 - 06:43 AM

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.
:: My Site ::
Feel free to critique...

#2 matte

matte
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 10 October 2006 - 06:50 AM

if you are wanting the program to run every 30 minutes i would use crontab on linux machine or task scheduler on windows machine

#3 TJMAudio

TJMAudio
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 10 October 2006 - 06:53 AM

What?

I just want part of my script to execute every 30 minutes, not a program.
:: My Site ::
Feel free to critique...

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 10 October 2006 - 07:12 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users