Running on Ubuntu Karmic. I need to execute the following (updated) script at boot time

# /etc/init.d/scripts
# Description: Starts Python scripts
# ————————————————–
# Provides: Scripts
# Required-Start: $network $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Start Python scripts to provide mapping services

case $1 in
    # echo -n ¨Starting Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
# echo -n ¨Stoping Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
# echo -n ¨Retarting Mapping service: ¨
/usr/local/bin/liteserv.py /home/myUN/bin/mapnik/my_osm.xml --caching --debug=False
# echo ¨Usage: scripts {start|stop|restart}¨
exit 1

Have placed it into /etc/init.d Registered it with

sudo update-rc.d scripts defaults

But nothing happens on boot. I have tried looking in the logs but I can't find anything. Both scripts and liteserv.py are marked as executable.

As per Andy Smith's response, When I run:

/etc/init.d/scripts start  

I now get the program running correctly (after correcting the bad quotes).
However, it still does not run the program on bootup.

  • 1
    It may sound stupid, but have you checked that the script is executable?
    – phunehehe
    Jan 31, 2011 at 12:39
  • Also, I think you mean sudo update-rc.d scripts default (without the s)?
    – phunehehe
    Jan 31, 2011 at 13:46
  • Additional to the above comment, have you tried running it manually with /etc/init.d/scripts start?
    – Andy Smith
    Jan 31, 2011 at 13:47
  • you should specify "at startup" a bit further... people might think "startup of when they log in".
    – akira
    Jan 31, 2011 at 15:21
  • From the help it appears ¨s¨ is required: update-rc.d [-n] <basename> defaults [NN | SS KK]
    – CarbonMan
    Jan 31, 2011 at 23:17

4 Answers 4


This is bizarre, but unless it is something that Stack Exchange is doing, I think the problem you are having is that you are using "fancy quotes" rather than "".

Whatever editor you are using may have replaced the standard quote character(Unicode U+0022) with stylized open and close quotes (U+201C and U+201D). sh doesn't like this very much. When I replace these stylized quotes with "normal quotes" your code works fine (with the small exception that I don't have the .py file it calls).

  • 1
    Thank you, thank you, thank you. Wasn´t the entire answer but it sure helped. I had copied and modified the code off the web and that is where the fancy quotes came from. However, the problem turned out to be the statement: ´case “$1″ in ´ It should have been ´case $1 in ´
    – CarbonMan
    Feb 1, 2011 at 10:07
  • 1
    Well, the quotes should work around the $1 provided that they aren't fancy quotes. Glad to hear it is worked out.
    – Steven D
    Feb 1, 2011 at 15:35
  • Turned out that my keyboard driver was messed up. Was wondering why I had to type " twice to get it to work: ubuntuforums.org/archive/index.php/t-299219.html Still having the original problem though, where the program won't run on boot.
    – CarbonMan
    Feb 2, 2011 at 1:28
  • @P Hemans: If you used a proper editor with syntax highlight (i.e. Vi) that could have been very obvious :P
    – kizzx2
    Feb 2, 2011 at 16:51

You can add your stuff to /etc/rc.local.

Otherwise, you could place your script into /etc/init.d/, chmod +x it and then run update-rc.d FOO defaults.

  • Yes that is pretty much what I have done. Starting it with "etc/init.d/scripts start" leads to errors as described in my comments (above)
    – CarbonMan
    Feb 1, 2011 at 1:06

Your script indicates it wants to be started in runlevels 3 and 5, stopped in runlevels 1 and 2 (plus 0 and 6 which are shutdown and reboot), and no opinion in runlevel 4. Ubuntu boots to runlevel 2 by default (I think this is still true with Upstart). So unless you set a different default runlevel your script won't run. In the script headers, use

# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
  • I have changed it as per your instructions, but I think I may have another problem as the script won't run with "start" (see above).
    – CarbonMan
    Feb 1, 2011 at 1:07

By adding:

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

at the beginning of the scripts file I was able to at least trap the error messages that was coming from the Python program (an authentication error with postgres). So the script is running at boot time (after much community input). It just fails during the run (which is a different problem).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .