Closed MoeinNS closed 3 months ago
You can't close the terminal and expect a process in it to run. But as an option you can create a scheduled task, so it starts whenever your computer starts, or you can use tmux.
Hi, I use Linux version and when I close the terminal your script stop working How can I close the terminal and the script still running?!
Install bot as service on Linux
Setting bot as service allows you to run it in backrgound and easily control.
root/example_folder
(for example)cd root/example_folder
git clone https://github.com/shamhi/HamsterKombatBot.git
cd root/example_folder/HamsterKombatBot
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
cp .env-example .env
.env
file using any code editor:
nano .env
(nano as example)main.py
and init session.cd /etc/systemd/system/
sudo touch hamsterbot.service
.service
file with content using any code editor:
sudo nano hamsterbot.service
(nano for example)
Content:
[Unit] Description=HamsterKombatBotService After=network.target [Service] User=root WorkingDirectory=/root/example/HamsterKombatBot/ Environment=PATH=/root/example/HamsterKombatBot/venv/bin/ ExecStart=/root/example/HamsterKombatBot/venv/bin/python3 /root/example/> HamsterKombatBot/main.py -a 2 Restart=always [Install] WantedBy=multi-user.target
User=
- user u running this service fromWorkingDirectory=
- path to cloned repository folderEnviroment=
- enviroment folder / venv value insertsExecStart=
- runner command
sudo systemctl daemon-reload
sudo systemctl enable hamsterbot.service
Now we are done.
Stop service:
sudo systemctl stop hamsterbot.service
Start service:
sudo systemctl start hamsterbot.service
Restart service:
sudo systemctl restart hamsterbot.service
Check status:
sudo systemctl status hamsterbot.service
Check logs:
sudo journalctl -u hamsterbot.service
Check logs in real time:
sudo journalctl -u hamsterbot.service -f
@MoeinNS @Mik-chan , check this out :3
@Sanlovty Hi bro and thanks for this
could you please create some docs like this for tapswapbot this method worked for tapswapbot but the last update ruined every thing
I describe the problem here
https://github.com/shamhi/TapSwapBot/issues/92
thanks again bro
Hi, I use Linux version and when I close the terminal your script stop working How can I close the terminal and the script still running?!