Ubuntu 9.10: how to troubleshoot a startup script that doesn’t appear to run

log-filesstartup-scriptstroubleshootingUbuntuubuntu-9.10

I've created a bash script 'foo'. I've made that script executable with

chmod+x 

and added it the the start-up by running

sudo update-rc.d foo defaults 80

Despite that, it doesn't appear to be working at startup. Is there a way to have my script echo messages to a log? Or is there some log that would record events/errors for this?

atm, I feel like I'm flying blind and don't really know how to troubleshoot this.

As requested, here is the content of my script:

#!/bin/bash
modprobe uinput
/home/dane/dev/mangler/run.sh /home/dane/dev/mangler/dane/keys.js

the run.sh command executes program kbd-mangler.exe. When running the following in a gnome-terminal it works:

~/$ sudo bash custom_keys.sh

Best Answer

At the beginning of your script, add this line:

exec > /tmp/debug-my-script.txt 2>&1

Reboot. Now look at that file in /tmp - it should tell you what's going on.

By the way, in init.d scripts I tend to use commands with full path (/sbin/modprobe). I've been burned so many times by the restricted PATH used by those scripts, I make no assumptions now. :)

By the way, good Bash programming links:

http://mywiki.wooledge.org/BashFAQ

http://mywiki.wooledge.org/BashPitfalls

http://mywiki.wooledge.org/BashGuide