Running python script from systemd

This forum is for topics dealing with problems with software specifically in the ARMv6h repo.

Running python script from systemd

Postby CD1 » Thu Apr 27, 2017 3:00 am

I'm not sure if this is the best place to ask this, but I have been trying to run a python script when my system boots without much success.

I have a systemd unit that looks like this

$this->bbcode_second_pass_code('', '[Unit]
Description=Example launcher script
After=network-online.target

[Service]
Type=idle
ExecStart=/usr/bin/python /home/user/my-script.py

[Install]
WantedBy=multi-user.target
')

And a simple python script that illustrates the issue like this:
$this->bbcode_second_pass_code('', '#!/usr/bin/env python
import time

print("Test started")

while(True):
time.sleep(1)
print("still alive...")
')

I expected that by checking journalctl -b -u launcher I should see that my script is running and producing output. However I just get the notice that the service has started and then nothing.

As a workaround I have set my system to autologin a user and call my python script in the ~/.bash_profile for that user. If I do it that way then my script does run how I want. Can anyone explain to me why this doesn't work how I thought it should?
CD1
 
Posts: 15
Joined: Mon Aug 01, 2016 2:09 am

Re: Running python script from systemd

Postby WarheadsSE » Thu Apr 27, 2017 12:32 pm

* Does this unit show a clean status (systemctl status launcher.service)
* Does the script rely on anything in a relative path? You may need `WorkingDirectory=`
* Does this service need any environment strings? You may need to use `Environment=` or `EnvironmentFile=`

(https://www.freedesktop.org/software/sy ... rvice.html)
(https://www.freedesktop.org/software/sy ... .exec.html)
(https://www.freedesktop.org/software/sy ... .unit.html)
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Running python script from systemd

Postby CD1 » Thu Apr 27, 2017 8:05 pm

I have a feeling this line from systemd is probably relevant:

$this->bbcode_second_pass_code('', 'Main PID: 246 (code=killed, signal=TERM)')

Will do some more reading on why that might be happening!
CD1
 
Posts: 15
Joined: Mon Aug 01, 2016 2:09 am


Return to ARMv6h

Who is online

Users browsing this forum: No registered users and 7 guests