β Like my work? Buy me a coffee! β paypal.me/RichCabo
Termux Maintenance Script
A fully automated script that scans, updates, repairs, cleans, and optimizes Termux for flawless performance.
Features
β Updates and upgrades all packages β Fixes broken dependencies β Clears cache and unnecessary files β Repairs storage and optimizes Termux β Restarts Termux for changes to take effect
Installation & Usage
1οΈβ£ Create the Script Manually
If you donβt want to download it, you can create it yourself:
- Open Termux and create the script using nano:
nano maintain.sh
- Copy and paste the following script inside nano:
#!/data/data/com.termux/files/usr/bin/bash
echo "π Starting Termux Full Maintenance Script..." echo "--------------------------------------------"
echo "π Checking storage access..." termux-setup-storage
echo "π Updating package lists..." pkg update -y && pkg upgrade -y
echo "π§ Fixing broken packages..." apt --fix-broken install -y
echo "ποΈ Cleaning unnecessary packages..." pkg autoclean && pkg clean && pkg autoremove -y
echo "ποΈ Clearing Termux cache..." rm -rf /data/data/com.termux/cache/*
echo "π οΈ Fixing storage and dependencies..." dpkg --configure -a
echo "π Checking disk space usage..." df -h
echo "π Checking package integrity..." apt list --installed > /dev/null 2>&1 && echo "β All packages are correctly installed."
echo "β»οΈ Restarting Termux..." am broadcast --user 0 -a android.intent.action.BOOT_COMPLETED
echo "β Maintenance Completed! Termux is now optimized."
- Save the file by pressing:
CTRL + X, then Y, and press Enter
2οΈβ£ Make the Script Executable
After creating the script, give it execution permissions:
chmod +x maintain.sh
3οΈβ£ Run the Script
Now you can execute it with:
bash maintain.sh
Alternative: Download & Run Automatically
-
Open Termux
-
Run this command:
pkg install -y wget && wget https://raw.githubusercontent.com/YOUR_GITHUB_USERNAME/termux-maintenance/main/maintain.sh && chmod +x maintain.sh && ./maintain.sh
(Replace YOUR_GITHUB_USERNAME with actual GitHub)
Automate the Script (Optional)
To run it automatically on Termux startup, add this to ~/.bashrc:
echo "bash ~/maintain.sh" >> ~/.bashrc
Or schedule it to run daily at 2 AM:
crontab -e
Then add this line:
0 2 * * * bash ~/maintain.sh
License
This project is open-source under the MIT License.