guix-devel
[Top][All Lists]
Advanced

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

Re: Shepherd timers


From: raingloom
Subject: Re: Shepherd timers
Date: Mon, 25 Mar 2024 09:14:39 +0000

On 2024-03-24 22:20, Ludovic Courtès wrote:
> Hello Guix!
> 
> I pushed to the ‘devel’ branch of the Shepherd a new module that
> implements “timers” along with ‘herd’ support to display information
> about them.
> 
> It lets you provide configuration like this one:
> 
> --8<---------------cut here---------------start------------->8---
> (use-modules (shepherd service timer))
> 
> (define timer
>   (service '(my-timer)
>            #:start (make-timer-constructor
>                     (calendar-event #:seconds '(0 7 15 22 30 45))
>                     (command '("sh" "-c" "echo Hi from $PWD.; sleep 20; echo 
> done")))
>            #:stop (make-timer-destructor)))
> 
> (register-services (list timer))
> (start-in-the-background '(my-timer))
> --8<---------------cut here---------------end--------------->8---
> 
> And then ‘my-timer’ invokes the given command at the moments that match
> the constraints defined by ‘calendar-event’—in this case any time the
> number of seconds is equal to 0, 7, 15, 22, 30, or 45.  You can also
> make it every Monday at 9AM etc., as you would expect.
> 
> The ‘herd’ command provides details information about the timer:
> 
> --8<---------------cut here---------------start------------->8---
> $ ./herd -s sock status my-timer
> Status of my-timer:
>   It is running since 21:09:32 (68 seconds ago).
>   Timed service.
>   Periodically running: sh -c "echo Hi from $PWD.; sleep 20; echo done".
>   Child process: 1814
>   It is enabled.
>   Provides (my-timer).
>   Requires ().
>   Will not be respawned.
> 
> Recent runs:
>   2024-03-24 21:10:04 Process exited successfully.
>   2024-03-24 21:10:19 Process exited successfully.
>   2024-03-24 21:10:26 Process exited successfully.
>   2024-03-24 21:10:34 Process exited successfully.
>   2024-03-24 21:10:35 Process terminated with signal 15.
> 
> Recent messages:
>   2024-03-24 21:10:29 Hi from /home/ludo.
> 
> Upcoming timer alarms:
>   21:10:45 (in 5 seconds)
>   21:11:00 (in 20 seconds)
>   21:11:07 (in 27 seconds)
>   21:11:15 (in 35 seconds)
>   21:11:22 (in 42 seconds)
> --8<---------------cut here---------------end--------------->8---
> 
> And of course you can do anything you can do with a service: stop it,
> unload it, load a replacement, and so on.
> 
> Feedback & suggestions welcome!
> 
> Ludo’.

Does it support RTC wakeup?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]