On Ubuntu, upstart has replaced System-V init. Since Ubuntu 15, systemd replaced upstart.
Adding a new daemon or service
Create your script
There should be existing scripts in
/etc/init/. Copy one of them and
modify it to suit your needs.
Sometimes the daemon you want to run should be run as a different user. Use the
command for this. In the case below the
teamcity user will be running the daemon.
I’ve placed this in
# Ubuntu upstart file at /etc/init/teamcity.conf start on runlevel  stop on runlevel  script exec start-stop-daemon --start --quiet --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run end script
Test your command
Test out the start-stop-daemon command manually.
# start-stop-daemon --start --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run
If it is working fine then your script is ready. Kill the job and in the next step start it via the upstart command.
Start the job
start command. The name of your job must match the name of your conf file in
# start teamcity teamcity start/running, process 7407
Reboot and check that your service automatically starts.
Stopping the job
stop command. If your job has forked upstart may have trouble stopping it.