Reading this thread How to run script at boot? [SOLVED] I want to do something similar to auto start my energy monitor (measureit) Having someissues though, wonder if anyone can help…
logs below…
thanks
root@osmc:/etc/systemd/system# systemctl status measureit.service -l
Your unit file looks visually ok, except I would change that after line to After=mediacenter.service - it’s best to be explicit about the unit type you are referring to.
However your errors suggest that the file is not being read properly - my first guess would be that you have windows line endings - did you originally write the file in vi or did you do it on a Windows PC ?
thanks for the reply.
Yea I originally copied the sshd.service and edited in vi. I did chmodd 777 it to appear like the sshd service.
When checking in winscp… the file seems a fair bit bigger than the others (all be it a few bytes)
Just tried copying sshd again to a fresh file and ensured I didnt get any dodgy line breaks etc and got the same result…
Anyone? Getting fed up of having to kill/respawn measureit every single day in order for the solar to be measured!
Any suggestions appreciated muchly!
ta v much.
thanks for the reply Berto
Na I was already running it under sudo bash shell.
yea dont know why thats missed out from the original text… it is already ExecStart=/usr/bin/python /var/www/html/measureit/measureit_system_files/python/data-input.py
Yay got it working… seems measureit was trying to write to /tmp/measureit.log so chmod 777 that and it started.
Now onto my next issue to get a cron job going to restart this 12:01 am every night as it seems theres a bug where my solar stops recording to pvoutput nightly… oh the joy!
thanks!
Out of curiosity, could you post how your script was setup to get logging into a “.log” file? From the link I posted above, I was actually trying to do this but it did not work. I just use the journalctl now, but would be interested to know how it could be made to work to a log file.
Does your .py script specify the log file directly? In other words, you are not using simple print statements?
had some dramas getting this to start on boot…It wasnt waiting for mysql to start. Even though the service fails coz it cant connect to mysql, systemd thinks all is fine n dandy so probably something wrong with how it returns errors too…
Tried putting mysql in after=, wants= but still no good. Tried adding a timeout too… Only thing that finally got it going was by using type=idle as below which will wait for everything to startup first…