My Python application needs to run on a Raspberry Pi 3 at startup and in a terminal.
What I did:
- I created a service
screenscript.service
in/etc/systemd/system
- a bash file in
/home/pi/mydir/screen.sh
- a python application in
/home/pi/mydir/code/hello.py
code 1, screenscript.service
Description=Terminal Service
After=network.target
[Service]
ExecStart=/home/pi/mydir/screen.sh
[Install]
WantedBy=multi-user.target
code 2, screen.sh
#!/bin/bash
cd home/pi/mydir/code
echo "work dir: '$(pwd)'" >> /tmp/log.log
/usr/bin/lxterminal -e "python /home/pi/mydir/code/hello.py"
code 3, hello.py
import threading
def printit():
threading.Timer(5.0, printit).start()
print "Hello, World!"
printit()
My issue:
I want to see 'hello world' continue display in a terminal, when I turn on the raspberry PI power.
My service failed
$systemctl status screenscript
---> shows loaded, enabled, active failed, code exited.
I can run this line $/usr/bin/lxterminal -e "python /home/pi/mydir/code/hello.py"