Re: Synchronising an app with the system clock



On Wed, Feb 14, 2007 at 07:28:38PM +0000, Alex Jones wrote:
> Hi list
> 
> I wrote	a quick app to alert me every time the clock strikes the hour.
> Unfortunately, I found no better way to do this than to check, every
> second, to see if the current local time's minutes and seconds are 0.
> 
> This involves a glib timeout of 1000ms, which I understand is not 100%
> guaranteed to work because it might skip from, e.g. 15:59:59.999 to
> 16:00:01.000 if I am unlucky and it actually takes 1001ms to fire. You
> might think to increase the resolution to 500ms, but then I need to keep
> track of state to make sure I don't fire the alarm twice. This quickly
> gets out of hand.
> 
> I initially thought of just checking the current time, and then
> calculating how long until the hour, and sleeping until then. There is a
> problem with this, however, in that if the time changes, the alarm will
> go off at the wrong time as it has no knowledge of the clock change.
> 
> What I want to do is have some way of absolutely synchronising an app
> with the system clock. I've considered a kind of D-Bus system clock
> service that could emit signals every second so that apps could
> synchronise to that and all dance in time, but that itself would need
> synchronising somehow, so the problem remains. Is there some way to
> interface with the kernel for this kind of thing?
> 
> Any other ideas/comments?

Add this to your crontab (crontab -e):

0 * * * *	for i in `seq \`date +%I\``; do play "bong.wav" ; done

--d

-- 
Davyd Madeley

http://www.davyd.id.au/
08B0 341A 0B9B 08BB 2118  C060 2EDD BB4F 5191 6CDA



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]