I am trying to run my own python script at startup. Or more specifically at the END of the boot sequence The python code does
a) writes to the I2C LCD screen
b) announces via sound that its 'Ready' When tested in a normal session this all works.
I tried, and suceeded, in creating a systemd service for this. The issue is that it runs too early - the screen is written to but the sound does not play.
My guess is this would need an 'After' directive in the service setup but I have no idea what to schedule it 'After'
Asking systemd for info yields a list of either 258 or 360 things its looking after - no help really.
I tried adding After=sound.target but that didn't help
So, is there a generic 'when-you-have-finished-all-your-stuff' thing that I could use to trigger my 'user' needs after all the 'system' needs ?
[Unit]
After=sound.target
Description=Execute this on boot
[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/jc/jcCode/at_start_pyscript.py
[Install]
WantedBy=multi-user.target
Thanks
JC 6 1 Answer
Try starting your script from cron using @reboot time specification. For example create a file /etc/cron.d/myscript with the following contents:
@reboot root /usr/bin/python3 /home/jc/jcCode/at_start_pyscript.py