debugging /etc/init.d startup scripts in Ubuntu

Have custom dropr message queue pollers I'm trying to start up via /etc/init.d in ubuntu. All 3 scripts are super-simple one liners and work perfect via command line, but for some reason, only one of them actually works when the server boots up. All have 775 perms, and this works great:

sudo /etc/init.d/ 

Here's an example script (has to run as www-data user):

[/etc/init.d]$  cat /etc/init.d/ 
su - www-data -c "bash -c '/path/to/dropr-server/daemons/app-poller.php'"

I've run removed / re-entered the inittab entries several times via:

updates-rc.d -f remove
updates-rc.d defaults

rcconf script also says everything is starting fine. I've followed all the instructions here: here and here:

And I've looked for output in all the usual suspects (/var/log/messages, /var/log/daemons, etc)... still no clue.

Would very much like to at least have some insight into why this is failing. Anyone know which logfiles I can reference to see what is going wrong & why?

Try calling the init-script while simulating the boottime environment:

env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" /etc/init.d/your-daemon start 

Do add some debug output to your script if you don't see any output from that command.



if [[ $debug_me == true ]]; then

  # Close STDOUT
  exec 1<&-
  # Close STDERR
  exec 2<&-


  # Open STDOUT as $LOG_FILE file for read and write.
  exec 1<>$LOG_FILE

  # Redirect STDERR to STDOUT
  exec 2>&1

  # Display shell commands with expanded args
  set -x


Run it in a sub-shell with -x.


上一篇: 由init.d启动的标准或最佳方式保持活动进程

下一篇: 在Ubuntu中调试/etc/init.d启动脚本