how to keep termux always online not to close session easily
To keep Termux always online and prevent the session from closing easily, you can follow these steps:
-
Use a reliable terminal emulator app: Install a terminal emulator app that provides a stable and reliable connection. Some popular options include Termux:API, JuiceSSH, or ConnectBot.
-
Use a persistent connection method: To prevent disconnections due to network issues or inactivity, you can establish a persistent connection using tools like tmux or screen. These tools allow you to create multiple virtual terminals within a single session.
-
Install tmux: Open Termux and run the following command:
pkg install tmux -
Create a new tmux session: To create a new tmux session, run the command:
tmux new-session -s session_name -
Detach from the session: To detach from the session without closing it, press
Ctrl+bfollowed byd. -
Reattach to the session: Whenever you want to reconnect to the session, open Termux and run the command:
tmux attach-session -t session_name
-
-
Utilize Termux:Boot (optional): If you want to automatically start Termux on boot, you can install the Termux:Boot package. This will allow Termux to launch in the background every time your device starts up.
-
Install Termux:Boot: Open Termux and run the following command:
pkg install termux-boot -
Configure Termux:Boot: After installation, run the following command to set up the Termux:Boot:
termux-bootThis will create a
~/.termux/boot/directory where you can add scripts that will be executed on boot.For example, you can create a script named
start_tmux.shin this directory and add the following content:#!/data/data/com.termux/files/usr/bin/sh tmux new-session -d -s session_nameSave the script and make it executable by running the command:
chmod +x ~/.termux/boot/start_tmux.sh
-
-
Disable battery optimization (optional): Certain devices aggressively optimize battery usage, which can lead to session disconnections. To prevent this, you can disable battery optimization for Termux:
- Open your device's Settings.
- Go to Battery or Battery Optimization.
- Find Termux in the list of apps.
- Set it to "Don't optimize" or "Not optimized".
By following these steps, you should be able to keep Termux always online and prevent the session from closing easily
原文地址: https://www.cveoy.top/t/topic/hTDI 著作权归作者所有。请勿转载和采集!