Closed tE3m closed 5 years ago
uhm you should create a service and enable with systemctl. follow this tutorial: https://timleland.com/how-to-run-a-linux-program-on-startup/
ExecStart= python3 main.py & should be work
Thanks for your quick answer, but it doesn't work. systemctl status <job_name>
outputs:
Dez 31 18:35:46 raspberrypi systemd[1]: [/etc/systemd/system/telegram.service:1] Assignment outside of section. Ignoring. Dez 31 18:35:46 raspberrypi systemd[1]: [/etc/systemd/system/telegram.service:3] Assignment outside of section. Ignoring. Dez 31 18:35:46 raspberrypi systemd[1]: [/etc/systemd/system/telegram.service:4] Assignment outside of section. Ignoring. Dez 31 18:35:46 raspberrypi systemd[1]: [/etc/systemd/system/telegram.service:8] Executable path is not absolute, ignoring: cd /home/pi/Projects/Telegram-InstaPy-Scheduling Dez 31 18:35:46 raspberrypi systemd[1]: telegram.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Do you know what to do?
No bro, I don't know
My solution is the /etc/xdg/lxsession/LXDE-pi/autostart
file. But there was a problem: an error occurs if one runs main.py
via python3 /path/to/main.py
because it can't find settings.json
. That's because it searches for settings.json
in the folder one is in instead of the Telegram-InstaPy-Schedule folder. I manually changed the main.py
so that it doesn't open(settings.json)
but open(my/path/to/settings.json)
. But I'm sure it's possible to create a variable in settings.json for db, like InstaPy does.
Hi! You can try to do:
cd /path/to ; python3 main.py
Is there any way of starting main.py everytime the computer starts? Cron and rc.local don't work from what I tested. My machine is a raspberry pi 3b+ that runs raspbian in cli mode.