I created a super basic init.d script for my python bot:

# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    echo "starting torbot"
    python /home/ctote/dev/slackbots/torbot/torbot.py
    # example: daemon program_name &

stop() {
    # code to stop app comes here
    # example: killproc program_name

case "$1" in
       # code to check status of app comes here
       # example: status program_name
       echo "Usage: $0 {start|stop|status|restart}"

And have set torbot.py to be +x and #!/usr/local/bin/python at the top. When I try to actually start it though, I get:

:/var/lock/subsys$ sudo service torbot start Failed to start torbot.service: Unit torbot.service not found.

Am I missing something?


If you are using ubuntu 16.04 or newer you may want to review the doc of systemd about creating service files

The script is for the old init system and is managed by a legacy compatibility layer.


For me, I'm using Ubuntu 16.04.

Firstly change the init function

. /etc/init.d/functions


. /lib/lsb/init-functions

Then in shell, create symbolic links from /etc/rc* to my script:

sudo update-rc.d <myapp> defaults 95
  • What means 95 here? – Gherman Dec 4 '17 at 15:24
  • @Gherman it's priority – turson Dec 6 '17 at 14:10

Ok, I tried some steps this stackoverflow answer(Running upstart script on 17.04?) and they worked My env is as follows

  1. Ubuntu at 17.10
  2. I have a python app on Gunicorn 19.x server, I need to start this application as a service.

Firstly you need to write a foo.service file.


WorkingDirectory=/path/to/your/working/directory/where the foo lives
ExecStart=/what/process/will call foo eg: in my case I used gunicorn app:app
ExecReload=/bin/kill -HUP $MAINPID 


The meaning of every word on the left hand side of the '=' sign and their equivalent in (to the earlier) upstart is in link https://wiki.ubuntu.com/SystemdForUpstartUsers

Once the file is ready, let's say you name it as 'foo.service' (the .service extension is important)

You need to place the file in /lib/systemd/system

After which you need to enable the service by calling

systemctl enable foo

Which will prompt you enter your root password as it will be creating symlinks.

If you have reached till here without any hassle , you are good. Your service is hence created Start is by calling

sudo service foo start

systemctl status foo to see the status sudo service foo stop to stop the service


Have you tired something like this? How do I debug Upstart scripts?

Can you provide the output to that this guide provides so that we can help you potentially debug your issue?


I had the same issue, this is the solution that worked for me. Try:

sudo systemctl daemon-reload

sudo systemctl enable daemon_app.service

sudo systemctl start daemon_app.service

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.