Creating the service file
I named my service file
sudo touch /etc/systemd/system/telegram-bot.service
And started editing it with
sudo vim /etc/systemd/system/telegram-bot.service.
I wanted this service to execute
python3.6 bot.py on boot, after connecting to the network, under my user (i.e. not as root).
The final form of the file:
[Unit] Description=Start telegram bot on boot Wants=network-online.target After=newtork.target network-online.target [Service] User=hlias Group=hlias ExecStart=/usr/local/bin/python3.6 bot.py WorkingDirectory=/home/hlias/my-fetch-bot [Install] WantedBy=multi-user.target
Enabling the service
sudo systemctl enable telegram-bot.service
Now, after every reboot, the service will be executed as we wanted.