Skip to content

Richoxd/Termux-Optimization-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

β˜• 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:

  1. Open Termux and create the script using nano:

nano maintain.sh

  1. Copy and paste the following script inside nano:

#!/data/data/com.termux/files/usr/bin/bash

echo "πŸ“Œ Starting Termux Full Maintenance Script..." echo "--------------------------------------------"

Ensure storage permissions

echo "πŸ” Checking storage access..." termux-setup-storage

Update package lists and upgrade packages

echo "πŸ”„ Updating package lists..." pkg update -y && pkg upgrade -y

Fix broken packages

echo "πŸ”§ Fixing broken packages..." apt --fix-broken install -y

Remove unnecessary packages and dependencies

echo "πŸ—‘οΈ Cleaning unnecessary packages..." pkg autoclean && pkg clean && pkg autoremove -y

Reset Termux cache

echo "πŸ—„οΈ Clearing Termux cache..." rm -rf /data/data/com.termux/cache/*

Fix and optimize storage

echo "πŸ› οΈ Fixing storage and dependencies..." dpkg --configure -a

Check disk space usage

echo "πŸ“Š Checking disk space usage..." df -h

Verify package integrity with a proper command

echo "πŸ” Checking package integrity..." apt list --installed > /dev/null 2>&1 && echo "βœ… All packages are correctly installed."

Restart Termux properly

echo "♻️ Restarting Termux..." am broadcast --user 0 -a android.intent.action.BOOT_COMPLETED

echo "βœ… Maintenance Completed! Termux is now optimized."

  1. 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

  1. Open Termux

  2. 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages