Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a script in ubuntu 9.04 in init.d that I've set to run on start on with update-rc.d using update-rc.d init_test defaults 99. All of the symlinks are there and the permissions appear to be correct

-rwxr-xr-x  1 root root   642 2010-10-28 16:44 init_test

mike@xxxxxxxxxx:~$ find /etc -name S99* | grep init_test
find: /etc/rc5.d/S99init_test
find: /etc/rc4.d/S99init_test
find: /etc/rc2.d/S99init_test
find: /etc/rc3.d/S99init_test

The script runs through source and ./ without issue and behaves correctly. Here is the source of the script:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          init test script
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

start() {
    echo "hi"
    echo "start called" >> /tmp/test.log
    return
}

stop() {
    echo "Stopping"
}

echo "Script called" >> /tmp/test.log

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    *)
        echo "Usage:  {start|stop|restart}"
        exit 1
        ;;
esac
exit $?

When the machine starts, I don't see "script called" or "start called" in the test.log at all. Is there anything obvious I'm messing up?

share|improve this question

migrated from stackoverflow.com Oct 29 '10 at 1:22

This question came from our site for professional and enthusiast programmers.

    
exit by itself gives you $? for free. –  Dennis Williamson Oct 29 '10 at 2:02

1 Answer 1

I figured out what was going wrong. There was a completely unrelated script that was getting blocked on startup because it was asking for an keypress from the user which seems to stall all other startup scripts. Is there a way to troubleshoot stuff like that such as logging which init.d scripts get run?

share|improve this answer
2  
If you put set -x in a shell script, it will print a trace of every subsequent command on its standard error. –  Gilles Oct 30 '10 at 1:11

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.