0

I'm on Ubuntu Mate, and I would like the system to run the command homebridgeat boot.

Do I just need to

sudo nano /etc/rc.local

and add this

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
homebridge
exit 0
earthmeLon
  • 11,042
  • 1
  • 36
  • 60
Kevin
  • 165
  • 1
  • 10
  • You are here so I'am guessing it didn't work. Make sure rc.local is executable and owned by root. – Rahul Jan 21 '17 at 23:56
  • 1
    But 16.04 and later seem to have no `/etc/rc.local`, so that post needs an updated answer I think – Zanna Jan 22 '17 at 11:55
  • Yes, but I'd have to recommend that you use **full system path** for `rc.local` and `cron`. – earthmeLon Jan 22 '17 at 19:03
  • Are you asking this question because it's not working, or are you asking this question because you want to make sure you've got it correct before you reboot? – earthmeLon Jan 22 '17 at 19:04
  • @Zanna I have a 16.04 VM (not upgraded) which has `rc.local` – muru Jan 23 '17 at 03:26
  • @muru oh oops it's only 16.10; I only have a `/lib/systemd/system/rc.local.service` and I am not sure how we are supposed to manage now. (My thought was from [No \`rc.local\` in 16.10, so how can I add a command to set brightness on boot?](//askubuntu.com/q/846212) ) So I still think we need an update to the dupe target. – Zanna Jan 23 '17 at 05:10
  • @Zanna for a single command, perhaps a new systemd unit: http://askubuntu.com/a/719157/158442 – muru Jan 23 '17 at 05:26
  • @muru indeed :) actually reading the file I mentioned [it looks like you could just create `/etc/rc.local` and make it executable](http://paste.ubuntu.com/23850544/) – Zanna Jan 23 '17 at 06:38
  • 1
    @Zanna yes, that works (remember to add an `exit 0` to it so that failed commands don't cause boot to hang or fail) – muru Jan 23 '17 at 06:39
  • @muru thanks! I added some notes to the accepted answer to the dupe target and voted to close this. – Zanna Jan 23 '17 at 06:49

1 Answers1

1

On systems with systemd in use rc.local might be ignored. In this post there's suggestions how to check that rc.local is really executed.

How can I make "rc.local" run on startup?

And make sure your remove the ">" signs in your example.

albert j
  • 1,433
  • 8
  • 12
  • 1
    +1 it's also important to consider whether the executable is in the default `PATH` (using an absolute path is a good idea, just in case) and what it does (or, more specifically, what environment and/or services it needs in order to run - such as a GUI/user session or networking services) – steeldriver Jan 22 '17 at 00:56