1

I want to run emacs as a daemon, on Ubuntu bootup.

The daemon call works, and the init script works, when called in a logged in session. However, when I boot my system, the emacs init script doesn't seem to have been run.

  • i) I can't call emacsc, and
  • ii) there's no evidence in /var/logs/boot*.
  • iii) in my shell, if I run emacs --daemon, I can then use the emacs client

Is there any special wand-waving to be done? Or any better way to trouble-shoot this issue?

migrated from serverfault.com Feb 10 '14 at 0:16

This question came from our site for system and network administrators.

  • What is your init script called and is it in the correct runlevel? To be sure if it starts include something like date > /tmp/test in it and after booting check if it's there. – Marki Feb 10 '14 at 0:22
  • Nice trick - thank-you. I was trying to think of a way of verifying that an init script was run. – Nutritioustim Feb 11 '14 at 23:48
1

That page in the Emacs wiki recommends running Emacs as user from an init script. This is not what init scripts were designed for, so I'm not surprised that it could cause issues.

Forget that and start the Emacs daemon from your .profile or from your crontab. Most modern cron implementations (and in particular Ubuntu's) allow the syntax

@crontab emacs --daemon

Or you could start Emacs on first use, by invoking

emacsclient -a ''

The service management framework isn't useful to manage Emacs.

  • I used .bash_profile, but essentially the same thing. Cheers. – Nutritioustim Feb 11 '14 at 23:49
  • @Gilles - 4 years later: would you still recommend the above method? For example, compared to the docs, which have way more config: emacswiki.org/emacs/EmacsAsDaemon – n1k31t4 Jan 17 at 8:41
  • 1
    @n1k31t4 These days you might use systemd to start the daemon, if you're running a not-too-old Linux. But definitely don't start Emacs from an init script. Init scripts are system-wide. Do it from the user systemd configuration. – Gilles Jan 17 at 12:33
0

The part of the accepted answer dealing with crontab doesn't work with the current version on Ubuntu 18. This is the correct incantation for crontab:

@reboot emacs --daemon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.