I have an annoucement bot and it would be a waste to run it all day for 1 announcement. So I am trying to schedule the start of server, start my bot, which on start anounces what it needs to and then schedule the shutdown 5 minutes later when it is surely done. I have installed the needed libraries and copied the code to the VM. If I try running the normal way by typing "python3 mybot.py" it works. I have also tried running it in tmux and it works in there as well. The problem is that I can't start it with the start up script. I don't know much bash so, so far I have tried:
- just moving to the folder and executing it normaly
#! /bin/bash
cd home/user
python3 bot.py
- moving to the folder and executing via a local bash file inside which was the command
#! /bin/bash
cd home/user
chmod +x run.sh
./run.sh
- starting the tmux session the same way and running the bot, but when I connected with ssh it wasnt on the list of active sessions.
I have also tried creating folder to check if it even executes and if I am at the right place and the folders did show up where I intended. Although it seems like it tries to execute the code in root despite creating the file at the place I moved to and finish the correct bash file. Also it might be because its a bot so its a continous code not like a script? I have also checked similar posts but couldn't understand fully/get them to work.
Any help is appreciated.