Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been trying to get sphinx to run at boot, so I added some lines to /etc/rc.local but nothing happens when I start up. If i run it manually it works however.

/etc/init.d/rc.local start works fine as does /etc/rc.local

It's listed in the default runlevel and is all executable but it does not work.

I am considering writing a separate init.d script to do the same thing but that's a lot of work for a simple task

dumbledore:/etc/init.d# ls -l rc*
-rwxr-xr-x 1 root root 8863 2009-09-07 13:58 rc
-rwxr-xr-x 1 root root  801 2009-09-07 13:58 rc.local
-rwxr-xr-x 1 root root  117 2009-09-07 13:58 rcS

dumbledore:/etc/init.d# ls /etc/rc.local  -l
-rwxr-xr-x 1 root root 491 2011-05-14 16:13 /etc/rc.local

dumbledore:/etc/init.d# runlevel
N 2

dumbledore:/etc/init.d# ls /etc/rc2.d/ -l
total 4
lrwxrwxrwx 1 root root  18 2011-04-22 18:53 K08vmware -> /etc/init.d/vmware
-rw-r--r-- 1 root root 677 2011-03-28 15:10 README
lrwxrwxrwx 1 root root  18 2011-04-22 18:53 S19vmware -> /etc/init.d/vmware
lrwxrwxrwx 1 root root  18 2011-05-15 14:09 S20ddclient -> ../init.d/ddclient
lrwxrwxrwx 1 root root  20 2011-03-10 18:00 S20fancontrol -> ../init.d/fancontrol
lrwxrwxrwx 1 root root  20 2011-03-10 18:00 S20kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root  27 2011-03-10 18:00 S20speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root  19 2011-03-10 18:00 S25bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root  20 2011-03-10 18:00 S50pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx 1 root root  15 2011-03-10 18:00 S50rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root  15 2011-03-10 18:00 S50saned -> ../init.d/saned
lrwxrwxrwx 1 root root  19 2011-03-10 18:00 S70dns-clean -> ../init.d/dns-clean
lrwxrwxrwx 1 root root  18 2011-03-10 18:00 S70pppd-dns -> ../init.d/pppd-dns
lrwxrwxrwx 1 root root  14 2011-05-07 11:22 S75sudo -> ../init.d/sudo
lrwxrwxrwx 1 root root  24 2011-03-10 18:00 S90binfmt-support -> ../init.d/binfmt-support
lrwxrwxrwx 1 root root  17 2011-05-12 21:18 S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root  22 2011-03-10 18:00 S99acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  21 2011-03-10 18:00 S99grub-common -> ../init.d/grub-common
lrwxrwxrwx 1 root root  18 2011-03-10 18:00 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx 1 root root  18 2011-03-10 18:00 S99rc.local -> ../init.d/rc.local

dumbledore:/etc/init.d# cat /etc/rc.local

#!/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.

# Start sphinx daemon for rails app on startup
# Added 2011-05-13
# Cannon Matthews
cd /var/www/extemp
/usr/bin/rake ts:config
/usr/bin/rake ts:start
touch ./tmp/ohyeah
cd -

exit 0

dumbledore:/etc/init.d# cat /etc/init.d/rc.local

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
    if [ -x /etc/rc.local ]; then
            [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
        /etc/rc.local
        ES=$?
        [ "$VERBOSE" != no ] && log_end_msg $ES
        return $ES
    fi
}

case "$1" in
    start)
    do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
share|improve this question
    
I have the same problem. When I execute /etc/rc.local my script is executed but the script is not executed from rc.local in ubuntu 10.04. –  user104359 Dec 16 '11 at 12:52
add comment

2 Answers

the problem is probably with changing directories. try putting all that in a separate script with a#!/bin/bash hashbang and call the script from rc.local.

share|improve this answer
add comment

One of the commands on your /etc/rc.local must be exiting with a non-zero status. Because of the -e parameter to sh on the first line this is causing the script to exit immediatly.

You can either remove the -e or find the responsible command and fix its error.

share|improve this answer
    
oh thats what -e does...but why would it run fine called explicitly –  loosecannon May 15 '11 at 21:16
    
I'm sorry but I'm not following, could you please clarify? Removing the -e won't actually fix the error of course, it will just make all the lines in the script execute regardless of whether there was a previous error. More like a "standard" shell script. –  Eduardo Ivanec May 15 '11 at 21:21
    
sorry that was sort of two comments: A realization of what the -e switch does and if i run /etc/rc.local it executes successfully, it seems like it should fail if something is going wrong –  loosecannon May 15 '11 at 22:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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