Systemd Service does not start on reboot

Posted on

Problem :

I have the following systemd service called startupsh.service placed in /etc/systemd/system/ on my raspberry pi running rasbpian.

Description=Service to start telegram bot

ExecStart=/usr/bin/ &


I also enabled the service with

sudo systemctl daemon-reload
sudo systemctl enable startupsh.service

And sudo systemctl is-enabled startupsh.service shows that the service is in fact enabled.
Furthermore, if I run sudo systemctl start startupsh.service everything is working as expected. However, if the pi gets rebooted the service does not execute and sudo systemctl status startupsh.service shows that the service is inactive (dead)

What is going wrong on startup? How can I fix thsi?

Edit: The scripts looks as follows

#!/usr/bin/env bash
echo "Starting Bot..."
source /home/pi/Desktop/Airdropfinder/airdropfinderEnv/bin/activate
python /home/pi/Desktop/Airdropfinder/airdropfinder/src/

Solution :

Add Restart=on-failure to your systemd unit file.



If set to on-failure, the service will be restarted when the process exits with a non-zero exit code

Leave a Reply

Your email address will not be published. Required fields are marked *