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?