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.
Asked
Active
Viewed 441 times
0
-
You should be able to run the Emacs daemon in `tmux` or `screen` as well. – undercat Mar 06 '19 at 03:03
-
You mean use the Emacs daemon in tmux but still use GUI Emacs? – Eric Hansen Mar 06 '19 at 03:10
-
Sure. Either this, or `nohup`/`disown`. – undercat Mar 06 '19 at 03:14
-
I have tried both nohup and disown unsuccessfully.. – Eric Hansen Mar 06 '19 at 03:22
-
1Any change, you're using Linux box with systemd-logind v230+, and you started emacs with emacs --daemon? You'll need to use systemd syntax to keep it running. – Danh Mar 06 '19 at 03:57
1 Answers
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
- Debian bug
- Arch linux changes from default
Rusi
- 479
- 4
- 12
-
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