I created the following script in /etc/init.d/bootscript.sh
The script has these permissions:
-rwxr-xr-x 1 root root 855 Aug 1 22:44 bootscript.sh

# /etc/init.d/bootscript.sh
# Provides:             bootscript.sh
# 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 bot named holt-bot

# Run my custom discord bot on boot.
case "$1" in
                echo "Starting holt-bot"
                nohup python3 /home/nick/code/python/holt-bot/holt-bot.py 2> /home/nick/python.log &
                echo "Stopping holt-bot"
                pkill -f holt-bot.py
                echo "Stopping holt-bot"
                pkill -f holt-bot.py
                echo "Starting holt-bot"
                nohup python3 /home/nick/code/python/holt-bot/holt-bot.py 2> /home/nick/python.log &
                echo "Usage: /etc/init.d/bootscript.sh {start|stop}"
                echo "$1" >> /home/nick/python.log
                exit 1

exit 0

When I run /etc/init.d/bootscript.sh followed by start, stop or restart it does what it is supposed to do.

However, when I reboot, or when I run sudo service bootscript.sh start, it fails to launch. I found this in sudo systemctl status bootscript.service:

Aug 02 10:05:45 raspberrypi systemd[1]: Starting LSB: Start daemon at boot time...
Aug 02 10:05:45 raspberrypi systemd[1]: bootscript.service: Control process exited, code=exited status=203
Aug 02 10:05:45 raspberrypi systemd[1]: Failed to start LSB: Start daemon at boot time.
Aug 02 10:05:45 raspberrypi systemd[1]: bootscript.service: Unit entered failed state.
Aug 02 10:05:45 raspberrypi systemd[1]: bootscript.service: Failed with result 'exit-code'.

I think this means that the script is called without any of the defined arguments? Should I fix that somehow, or should I make the script work without arguments? Or is the problem something else entirely?

  • Odd that it starts from the command line since the shebang is missing. Maybe adding a proper shebang will make it work as a service? BTW: why not create a proper systemd service file? Much easier to set up and more control over startup, etc.
    – Dirk
    Aug 2, 2018 at 18:25
  • @Dirk I tried the shebang but it didn't make any difference and I ended up not adding it again. Valid point on the systemd though. I didn't really know the best way to run a script at boot, a bit of googling resulted in this, honestly the fact that it works as a service is secondary here. Aug 2, 2018 at 18:32
  • Error code 203 indicates 'no such file or directory' so I would add full paths anywhere and add the standard shebang.You can also add to the PATH environment variable at the start of the script to make sure the script can find everything it needs.
    – Dirk
    Aug 2, 2018 at 18:41
  • Could it be that a certain file can't be found due to permissions? (and related, isn't this executed with root permissions?) Aug 2, 2018 at 18:43
  • Sorry, don't know. And I don't want to put too much energy in an outdated method,,,
    – Dirk
    Aug 2, 2018 at 18:49

1 Answer 1


Root has a different PATH than you do. Instead of python3, you should be using /usr/bin/python3 (or wherever python3 is installed in your system).

I've ran into this a few times, myself.

  • It seems this is not the issue. I think python3 is a valid command and not an alias. When executing which python3, i get /usr/bin/python3 both as my own user and as root. Or does that have anything to do with the way I change from my own user to the root user (sudo su)? I changed my script on the Pi, but i'll keep the original here to avoid confusion. Aug 2, 2018 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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