From: Trastabuga
Subject: Timers (or signals) in Lisp
Date: 
Message-ID: <dc2900e7-c937-465b-8a43-4a1bc948bfdc@8g2000hse.googlegroups.com>
I have a Lisp daemon running on my Linux system (hunchentoot +
utilities).
I need to process some recurring tasks (some have to be performed
daily some monthly).
I am wondering what is the best approach to take in this case?
I saw timer project for SBCL and it looks promising but I may restart
the daemon so it'll loose track of the exact time when to perform the
task. I was thinking of Linux cron, but I am not sure how it can send
a message to linux process at a certain time and if it's a viable
approach for my case... So, any input is welcome!

Thank you,
Andrew

From: Volkan YAZICI
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <ef5caedf-b7f9-4124-83f1-67e5eaf46277@79g2000hsk.googlegroups.com>
Hi,

On Jun 18, 7:53 pm, Trastabuga <·········@gmail.com> wrote:
> I have a Lisp daemon running on my Linux system (hunchentoot +
> utilities). I need to process some recurring tasks (some have
> to be performed daily some monthly). I am wondering what is the
> best approach to take in this case?

While the *best* approach may vary, there are two ways I'd
probably go with:

1. I'd use a client/server architecture using some sort of RPC
   technology. (See s-xml-rpc, cl-json, usocket, vs.) A job
   scheduled by cron will periodically try to invoke related
   RPC functions in the server side.

2. Periodically print/poll current epoch timestamp to/from a
   static filepath. (e.g. /var/run/foo-soft) Periods will vary
   according to required granularity.

I'm inclined to prefer solutions portable across different OS
and CL implementations. But that totally depends on your taste.


Regards.
From: =?UTF-8?B?TGFycyBSdW5lIE7DuHN0ZGFs?=
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <48593f48$0$2326$c83e3ef6@nn1-read.tele2.net>
Trastabuga wrote:
> I have a Lisp daemon running on my Linux system (hunchentoot +
> utilities).
> I need to process some recurring tasks (some have to be performed
> daily some monthly).
> I am wondering what is the best approach to take in this case?
> I saw timer project for SBCL and it looks promising but I may restart
> the daemon so it'll loose track of the exact time when to perform the
> task. I was thinking of Linux cron, but I am not sure how it can send
> a message to linux process at a certain time and if it's a viable
> approach for my case... So, any input is welcome!
> 
> Thank you,
> Andrew

http://www.sbcl.org/manual/Timers.html

..sb-ext:schedule-timer takes an :absolute-p argument. Maybe you can use that?

I suppose that that absolute point in time might pass while the program isn't running. You could save the next point in time to a file, then check that file on startup; 

  * "has this point in time already passed?"

..and if needed..

  * "should something have been done more than once since that point in time?" (has more than one day passed when goal is to do something each day)

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: Rupert Swarbrick
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <g3bgpq$er8$1@news.albasani.net>
--=-=-=
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Lars Rune N=F8stdal <···········@gmail.com> writes:

> Trastabuga wrote:
>> I have a Lisp daemon running on my Linux system (hunchentoot +
>> utilities).
>> I need to process some recurring tasks (some have to be performed
>> daily some monthly).
>> I am wondering what is the best approach to take in this case?
>> I saw timer project for SBCL and it looks promising but I may restart
>> the daemon so it'll loose track of the exact time when to perform the
>> task. I was thinking of Linux cron, but I am not sure how it can send
>> a message to linux process at a certain time and if it's a viable
>> approach for my case... So, any input is welcome!
>>
>> Thank you,
>> Andrew
>
> http://www.sbcl.org/manual/Timers.html
>
> ..sb-ext:schedule-timer takes an :absolute-p argument. Maybe you can use =
that?
>
> I suppose that that absolute point in time might pass while the
> program isn't running. You could save the next point in time to a
> file, then check that file on startup;=20
>
>  * "has this point in time already passed?"
>
> ..and if needed..
>
>  * "should something have been done more than once since that point in ti=
me?" (has more than one day passed when goal is to do something each day)
>
> --=20
> Lars Rune N=F8stdal
> http://nostdal.org/

Hmm, I don't know anything great offhand, but it seems this is the
problem that anacron [1] tries to solve. Maybe there will be some nice
ideas in the code for that?

Rupert


[1] http://anacron.sourceforge.net/

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iJwEAQECAAYFAkhZRnoACgkQRtd/pJbYVoaM9QQAidb680nD5SuqEa5JTp5YcIpy
GYhbXVLTZ/6WS0L241YmfQjhGUJ9PP+NRht2R7tvTDD+mP74F+wTKV09Ck5cWXWh
nOH3WJmMV2iQyuoLSC5ijyWoWVo9zZtXxSr9O+1N8qPX2ziYDaIl0do4XSMLdVXC
TQwdWVbf017ozxfwu7s=
=V5uP
-----END PGP SIGNATURE-----
--=-=-=--
From: Trastabuga
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <5d3645ac-6271-41cb-8b42-9167b033ba3f@x41g2000hsb.googlegroups.com>
On Jun 18, 1:31 pm, Rupert Swarbrick <··········@gmail.com> wrote:
> Lars Rune Nøstdal <···········@gmail.com> writes:
>
>
>
> > Trastabuga wrote:
> >> I have a Lisp daemon running on my Linux system (hunchentoot +
> >> utilities).
> >> I need to process some recurring tasks (some have to be performed
> >> daily some monthly).
> >> I am wondering what is the best approach to take in this case?
> >> I saw timer project for SBCL and it looks promising but I may restart
> >> the daemon so it'll loose track of the exact time when to perform the
> >> task. I was thinking of Linux cron, but I am not sure how it can send
> >> a message to linux process at a certain time and if it's a viable
> >> approach for my case... So, any input is welcome!
>
> >> Thank you,
> >> Andrew
>
> >http://www.sbcl.org/manual/Timers.html
>
> > ..sb-ext:schedule-timer takes an :absolute-p argument. Maybe you can use that?
>
> > I suppose that that absolute point in time might pass while the
> > program isn't running. You could save the next point in time to a
> > file, then check that file on startup;
>
> >  * "has this point in time already passed?"
>
> > ..and if needed..
>
> >  * "should something have been done more than once since that point in time?" (has more than one day passed when goal is to do something each day)
>
> > --
> > Lars Rune Nøstdal
> >http://nostdal.org/
>
> Hmm, I don't know anything great offhand, but it seems this is the
> problem that anacron [1] tries to solve. Maybe there will be some nice
> ideas in the code for that?
>
> Rupert
>
> [1]http://anacron.sourceforge.net/
>
>  application_pgp-signature_part
> 1KDownload

I was trying to find a sample code for SBCL which handle a signal, but
I couldn't...
I like the idea of some lisp-independent process like cron (or
anacron) to run independently of lisp and just send signals to the
lisp process. Is there a sample code on how to handle signals in CL
(or SBCL in particular?)?

Thank you,
Andrew
From: Zach Beane
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <m3skvahb20.fsf@unnamed.xach.com>
Trastabuga <·········@gmail.com> writes:

> I was trying to find a sample code for SBCL which handle a signal, but
> I couldn't...
> I like the idea of some lisp-independent process like cron (or
> anacron) to run independently of lisp and just send signals to the
> lisp process. Is there a sample code on how to handle signals in CL
> (or SBCL in particular?)?

See SB-SYS:ENABLE-INTERRUPT.

I have a program that handles SIGWINCH with something like this:

  (sb-sys:enable-interrupt sb-posix:sigwinch #'update-window-size)

Zach
From: D Herring
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <Ef6dnRFn6d4Jt8DVnZ2dnUVZ_srinZ2d@comcast.com>
Zach Beane wrote:
> Trastabuga <·········@gmail.com> writes:
> 
>> I was trying to find a sample code for SBCL which handle a signal, but
>> I couldn't...
>> I like the idea of some lisp-independent process like cron (or
>> anacron) to run independently of lisp and just send signals to the
>> lisp process. Is there a sample code on how to handle signals in CL
>> (or SBCL in particular?)?
> 
> See SB-SYS:ENABLE-INTERRUPT.
> 
> I have a program that handles SIGWINCH with something like this:
> 
>   (sb-sys:enable-interrupt sb-posix:sigwinch #'update-window-size)

Signals can be problematic -- there aren't enough of them.  You might 
consider fifos (mkfifo) or interprocess mutexes instead.

- Daniel
From: Jeff
Subject: Re: Timers (or signals) in Lisp
Date: 
Message-ID: <0ae0ca15-beba-4920-9d3d-a5ace225ce9f@8g2000hse.googlegroups.com>
On Jun 18, 12:53 pm, Trastabuga <·········@gmail.com> wrote:
> I have a Lisp daemon running on my Linux system (hunchentoot +
> utilities).
> I need to process some recurring tasks (some have to be performed
> daily some monthly).
> I am wondering what is the best approach to take in this case?
> I saw timer project for SBCL and it looks promising but I may restart
> the daemon so it'll loose track of the exact time when to perform the
> task. I was thinking of Linux cron, but I am not sure how it can send
> a message to linux process at a certain time and if it's a viable
> approach for my case... So, any input is welcome!
>
> Thank you,
> Andrew

Portable threads has scheduled functions that are reasonably simple to
bolt on to an existing project.

Jeff Ober
artfulcode.net