Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 17366

Re: Python script as background process

$
0
0

Hello bpryer

 

I spent some time tonight trying to solve your problem.

I made a python example "blink.py" which blink the on-board led on the Arduino breakout board

 

#!/usr/bin/python
import mraa
import time

x = mraa.Gpio(13)
x.dir(mraa.DIR_OUT)

while True:
    x.write(1)    time.sleep(0.5)    x.write(0)    time.sleep(0.5)

 

I thought at first than the method described here would work:

http://serverfault.com/questions/34750/is-it-possible-to-detach-a-process-from-its-terminal-or-i-should-have-used-s

However, "disown" does not exist on Yocto

 

I found a solution using "systemctl"

some info here : Re: Startup scripts on Edison

 

What I did is create a blink service "/lib/systemd/system/blink.service" with this content :

[Unit] Description=Blink! [Service] ExecStart=/home/root/blink.py [Install] WantedBy=multi-user.target

 

After that you have to reload your services with

systemctl daemon-reload

 

and then you can start or stop your program with

systemctl start blink

systemctl stop blink

 

When it is started, it will continue to run even after you terminate you SSH session.

 

You can also make it auto-start at boot with

systemctl enable blink


To see if your process is running and/or enabled use

systemctl status blink

 

I hope it helps!

 

 


Viewing all articles
Browse latest Browse all 17366

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>