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
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.
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/
--=-=-=
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-----
--=-=-=--
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
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
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
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