аватар question@mail.ru · 01.01.1970 03:00

Automobile load .py script on Linux

Friends Hello everyone, I bought rangepi for myself to make a server for telegram bots, I need the bots to start after rebooting the device, I tried many ways but at least one helped somehow: sudo crontab -e I recorded this:

 Class = "" Data-highlighted = ""> @reboot python3 /home/orangepi/bots/weather_bot/weather_bot.py & amp; python3 /home/orangepi/bots/echo_bot/main.py & amp;      

I seemed to have helped, but I went through a couple of hours and the bots stopped working, and so it was further when I renoved the device, it passes a couple of hours and all the bots are inactive what to do?

аватар answer@mail.ru · 01.01.1970 03:00

as an option, if you have Systemd

  Sudo Nano /etc/syStemd/system/&ilt ;yur_bot_name> On your parameters: 

  [unit] description = & lt; your bot Description & gt; after = network.target [service] type = simpleuser = & lt; user name from which you launch scripts & gt; group = & lt; a user group from which you launch Scripts & gt; environment = pythonpath = & lt;/full/to/to/directory/with/yur/script & gt; workingDirectory = & Lt;/Full/to/to/Directory/with/your/script & gt; execstart = & LT;/Full/Path/to/Python & GT; & lt;/Full/Path/to/your/script & gt; restart = alwaysrestartSec = 5 [insta ll] wantedby = network.target    

further: ctrl+x, y to save the unit file that was just created

then

  Sudo Systemctl Daemon-Reloadsudo Systemctl Start & Lt; Youur_bot_name & Gt; .Serviceesudo Systemctl Status & Lt; YOUR_BOT_NAME & GT; .Service # If all the norms and unit have started ...  sudo systemctl  enable  & lt; your_bot_name & gt; .Servicee                                      

Latest

Similar