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.
1 Answer
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
- Debian bug
- Arch linux changes from default
-
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.– JdeBPMar 6, 2019 at 7: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.– RusiMar 6, 2019 at 16:28
tmux
orscreen
as well.nohup
/disown
.