complete-computing-environment/async_forever.org

1.2 KiB

Running Things in Emacs Forever

In The Complete Computing Environment there are a number of processes that I run that I want to have more visibility in to than if they were running as SystemD User Services. They may die, they may start to spawn errors, I want to know if it's failing or misbehaving. Right now this is mainly used in my OfflineIMAP setup, but I maintain it here and use it for one-off solutions.

(defun cce/async-forever (command buffer-name &optional seconds)
  "Run a command in an async buffer forever"
  (save-window-excursion
    (async-shell-command (concat "while true; do " command "; sleep " (prin1-to-string (or seconds 5)) "; done")
                         (get-buffer-create buffer-name))))