0

My current work workflow includes using PuTTY to SSH into a Linux development box with many users. I use an Emacs daemon to avoid the long startup times when closing my Emacs sessions. However, the Emacs daemon dies upon ending my SSH session. I was wondering if there is a way to spawn the daemon such that it persists beyond closing the SSH session? The only solution I have seen thus far is to use Emacs inside Tmux, however I much prefer the GUI Emacs.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

1 Answers1

2

Fleshing out the suggestion of @Danh to use systemd

Simple solution

Recent emacs has improved it's support for emacs as a service. This includes

  • the new fg-daemon option
  • an accompanying systemd service file

In your case you will also need to use lingering1 (lingering2) and the settings KillUserProcesses

Less simple

[You are using an earlier emacs that does not have fg-daemon]

In that case you must use type=forking. That requires also PIDFile=. AFAIK old Emacs doesn't provide this but here's a hack.

Allowing systemd to guess the pid works sometimes but is not recommended by systemd and should be treated as broken by default.

See also

  1. Debian bug
  2. Arch linux changes from default
Rusi
  • 489
  • It's not just systemd service units, either. Since 2016, there has been a service bundle, that normally goes in ~/.config/service-bundles/services/emacs, for running emacs 26 or later with --fg-daemon as a per-user service under the nosh toolset's per-user service management. – JdeBP Mar 06 '19 at 07:57
  • @Erichansen Nice to see that you've accepted my suggestions. It would be good (for future readers) to see what combo of my suggestions worked for you. Updating your question with this would be best. Though just a comment "Followed no 2" or whatever also fine. – Rusi Mar 06 '19 at 16:28