-1

I've created my own Service with systemd. It is supposed to run a python script once at boot time. It sends an Email with the IP-Address and the Teamviewer id, this is why i have an delay in it, otherwise i get an error that the domain of the Mailserver cant be resolved. The Script should run in the background because of the 30 seconds delay. The script is located in /usr/bin/glatv.py and is ecexuteable, the script run without an problem. The construct is runnning on an Raspberry Pi4 with Raspian Buster 2020-02-13

The Service is in /etc/systemd/system/ located, is executeable and enabled:

[Unit]
Description=My Own Service

[Service]
Type=oneshot
ExecStart=/usr/bin/glatv.py &

[Install]
WantedBy=reboot.target

But

systemctl start myservice 

is working without a Problem

 ● glatvd.service - My Own Service
   Loaded: loaded (/etc/systemd/system/glatvd.service; enabled; vendor preset: enabled)
   Active: inactive (dead)

Apr 02 12:52:31 raspberrypi systemd[1]: Starting My Own Service...
Apr 02 12:53:02 raspberrypi systemd[1]: glatvd.service: Succeeded.
Apr 02 12:53:02 raspberrypi systemd[1]: Started My Own service.

after a reboot there is no call or log

2 Answers2

0

You should try run this command to make your service enable to run after restart

systemctl enable myservice

and for log, I believe you must put this parameters into your service's config file

StandardOutput=/path/to/info/log/info_log.log
StandardError=/path/to/error/log/error_log.log

Anything I got this reference: How to redirect output of systemd service to a file

Luctia
  • 322
  • 1
  • 5
  • 17
0

Instead of having an arbitrary 30-second delay, add this to your service file:

After=network-online.target
Wants=network-online.target
stark
  • 12,615
  • 3
  • 33
  • 50