1

I have some commands that I need to run at startup. I wanted to put them in /etc/rc.local but this doesn't work (bug report).

I've seen a number of different workarounds and I'm sure they all work, but I'm wondering if there is a preferred or even best way to do it? I mean one that might avoid potential complications, or one that may be considered to be best practice in such a situation?

I'm using Linux for business purposes (since Windows died on me yesterday). I'm keen to avoid causing more issues than I am fixing. Thanks in advance.

Jorge Castro
  • 73,717

2 Answers2

2

You should still use /etc/rc.local unless you yourself can confirm that rc.local isnt working.

After consulting with micahg (IRC user) who is on bugsquad and bugcontrol, we've confirmed that /etc/rc.local runs as expected behavior is on 12.04. As the bug you mentioned is "Incomplete", it is likely an edge-case bug and not a bug that is confirmable.


What I would have put on a comment on that bug (but did not after talking with micahg) is this (note that a bunch of it is context-specific for the bug)

rc.local does indeed boot on a clean 12.04 installation. I have confirmed that rc.local does correctly work, after numerous changes to the file and numerous reboots.

I have 30 different commands which activate or deactivate certain services, and run specific services that are not in /etc/init.d/ or upstart. Each and every one of those commands has correctly run (just tested) on a clean 12.04 installation.

Since /etc/rc.local requires superuser to edit, i do not think its getting overwritten or overridden by the desktop, except in certain circumstances where a graphics driver is taking over settings (or a GUI taking over settings for instance for backlight or screen brightness on laptops, which I tend to see happen when a proprietary graphics card's drivers and software are used), in which case /etc/rc.local is most likely being run, but the GUI and relevant software starting afterwards is running additional commands and directives post-rc.local runtime.

This needs additional testing with numerous different command combinations, but expected behaviour of rc.local is indeed occurring on standard 12.04 and 11.04 tests I have run.

Thomas Ward
  • 78,878
2

I realize this an old post....But this is what helped be with automatically mounting windows shares in a ubuntu vitualbox. I added a 10 second pause before my commands.

#!/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.
sleep 10 
<script to be run>
exit 0
Rich
  • 51