Reply to Re: working as a daemon and execute tasks at a certain time

Your name:

Reply:


Posted by FD on 10/10/07 13:58

"Dirk Laurenz" <dirk.laurenz@fujitsu-siemens.com> schreef in bericht
news:feic0q$qc2$1@nntp.fujitsu-siemens.com...
> Hello,
>
> i've written a daemon in php and everthing works fine.
> i'm able to execute tasks periodically. for example every 900 seconds.
>
> now i want the daemon to do a task only once a day,
> for example at 1800 hours. but i'm not sure how to do
> this.
> saying something like
>
> while (true)
> {
> if ($current_time==1800) dosomething
> }
>
> fails if i miss 1800 exactly.
> saying something like
>
> while(true)
> {
> if ($current_time<=1801 && $current_time=>1800) dosomething
> }
>
> leads to running the function twice, or more depending on
> the execution time of the function.
>
> I'm using php 4.3 (more is not allowed at the moment)
>
> Thanks for any help....
>
> Greetings, Dirk


1800 hours happens only once a day, so you must keep track of the last day
that the task is done.

$done_day = 0;
while (true)
{
if ($done_day <> today() && $current_time >= 1800)
{
$done_day = today();
dosomething...
}
}

today() should return the current day of the week, month or year.

Frank

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация