I’m having trouble running a “program” as a service on my dietpi

I followed these instructions

  • Open another SSH session (Putty or SSH client) and login to the PI.

  • All following actions must be done on this second SSH login instance!

  • Setting YAP to run automatically as a service

  1. sudo nano /etc/systemd/system/yap.service

Copy and paste the following on the opened window:

[Unit]

Description=A simple proxy for SSTV and Plex DVR

[Service]

WorkingDirectory=/home/pi/yap

ExecStart=/usr/bin/python3 sstvProxy.py -hl

Restart=on-failure

RestartSec=5

[Install]

WantedBy=multi-user.target

Press Ctrl and x together

Press Y to save, and press the enter key again to save the file

  • Now enable the service so it starts every time you reboot:
  1. sudo systemctl enable yap.service
  • Now reboot
  1. sudo reboot

But it doesn’t work. The program still isn’t running in the “background” I have to have an ssh window open with it actively running for it to work. Any help would be greatly appreciated

Could you post the output of three commands:

  1. systemctl list-unit-files | grep enabled
  2. which python3
  3. ls -l /home/pi/yap/sstvProxy.py
1 Like

Thx, just figured it out. Since I was using dietpi it was

WorkingDirectory=Root/yap

Instead of

WorkingDirectory=/home/pi/yap

Thank you

How did you learn linux btw?

@aaiyar learned it the same way everyone else has. We install it and break it so many times we eventually learn what NOT to do :smiley:

2 Likes

I think I’m going to take an. Online course, any suggestions?

1 Like

I never took any courses... I have been using linux since 1997.

2 Likes

@frmWink2Hubitat

@Evilborg is exactly correct. I installed Linux on Gateway 2000 386-20 (8 megs RAM, 60 meg HD) in the fall of '93 using a Yggdrasil "live-CD" distribution. TeX had just been ported to Linux around that time and it was incredible to sit at my desk and write as opposed to reserving terminal time elsewhere.

I switched to Slackware within a month or two, and many years later to Debian (and then Ubuntu).

1 Like

I started with RedHat before there was a GUI install. After a few years on RH I switched to Mandriva(defunk now) then Debian which I have used for the last 15 years.

2 Likes

@aaiyar help, please. My pi crashed and I reset this up. Program runs perfect except the last step, getting it to run as a service, I keep getting “bad message “ any idea why? @erktrek arent you a Linux head as well? :joy:



Yeah sort of... :nerd_face:

Maybe something like this would work?

[Unit]
Description=A simple proxy for SSTV and Plex DVR
After=multi-user.target

[Service]
Type=simple
Restart=on-failure
WorkingDirectory=/root/yap
ExecStart=/usr/bin/python3 /root/yap/sstvProxy.py 
RestartSec=5s

[Install]
WantedBy=multi-user.target

Note: "dietpi" is the host name not the root. Also made sure relevant entries were on separate lines, added full paths to ExecStart (maybe not needed, but just in case) and the RestartSec added "s" for secs..

Here's an example of a python script:

did you forget the first character at the top - "[" ?

[Unit]

Also feel free to PM me since this is not quite HE stuff... but happy to help where I can.

2 Likes

Hot damn, it worked. After 4 hours of trying last night and 2 hours today. Thank you

3 Likes