Since you are running Ubuntu 16.04 which by default uses systemd
you should write a systemd
service unit to control the startup behaviour of your application.
A simple systemd
unit file looks like as follows, assuming mono
is at /usr/bin/mono
since the ExecStart
line must begin with an absolute path.
Save this in /etc/systemd/system/my-mono-app.service
.
[Unit]
Description=my mono app
# If the service relies on network uncomment the next line.
#After=network.target
[Service]
Type=Simple
ExecStart=/usr/bin/mono /home/yahniukov/Documents/programs/my_programs/game_backup/backup.exe <your-parameters>
[Install]
WantedBy=multi-user.target
You have added "$@"
which implies that there are some parameters passed to your command, so you have to replace <your-parameters>
with the ones actually used.
You also could use the systemd
options Environment
or EnvironmentFile
to store this. For more information have a look in the man pages systemd.unit
, systemd.service
and systemd.exec
.
After you have created the file, execute the command as follows to tell systemd
that there was a change.
systemctl daemon-reload
Now you should be able to control the service as follows. For a full description see man systemctl
.
systemctl status my-mono-app
systemctl start my-mono-app
systemctl stop my-mono-app
systemctl restart my-mono-app
To enable the service as start up, you have to enter the command as follows.
systemctl enable my-mono-app
Depending on the behavior of your script and application, it might be necessary to change the Type=simple
part to oneshot
or forking
. Not that you have to run systemctl daemon-reload
after you have made changes to the my-mono-app.service
file to pick up the changes.