Hi everyone,
I wanted to share a clean and completely automated script I set up on Zorin OS Lite to handle system updates (APT & Flatpak) and disk cleanup automatically at startup.
Why use this?
Many automation scripts trigger an annoying password prompt or fail silently in the background because of sudo restrictions. By using system Cron, this script runs invisibly with root privileges right after your PC turns on, without asking for any password.
Step 1: Create the script
Create a file named cleanup.sh in your home folder (/home/USERNAME/cleanup.sh) and paste this code:
#!/bin/bash
# 1. Wait 120 seconds for the network connection to be fully established
sleep 120
# 2. Redirect all outputs to a log file for easy verification
exec > /tmp/cleanup_execution.log 2>&1
echo "=================================================="
echo " STARTING ZORIN UPDATES AND CLEANUP "
echo "=================================================="
# 3. Update system packages (APT)
echo -e "\n[1/5] Updating system packages..."
apt-get update
apt-get upgrade -y
# 4. Update Flatpak applications
echo -e "\n[2/5] Updating Flatpak apps..."
flatpak update -y
# 5. Remove useless APT packages and clean cache
echo -e "\n[3/5] Cleaning up system packages..."
apt-get autoremove --purge -y
apt-get clean -y
# 6. Clean system journals (Keep logs under 50M)
echo -e "\n[4/5] Vacuuming system journals..."
journalctl --vacuum-size=50M
# 7. Clean XFCE thumbnail cache
echo -e "\n[5/5] Cleaning XFCE thumbnail cache..."
rm -rf /home/USERNAME/.cache/thumbnails/*
echo "=================================================="
echo " UPDATES & CLEANUP COMPLETED! "
echo "=================================================="
Replace USERNAME by your actual name
Make it executable by running this command in your terminal:
chmod +x /home/USERNAME/cleanup.sh
Step 2: Automate it with Cron
Open the root crontab in your terminal:
sudo crontab -e
Go to the very bottom of the file and add this single line:
@reboot nice -n 19 /home/USERNAME/cleanup.sh
(The nice -n 19 ensures the script runs with the lowest CPU priority, so it won't slow down your computer while you start working!)
How to check if it worked?
After a reboot, you can verify that Cron triggered the script by running:
sudo grep -i "cleanup.sh" /var/log/syslog
And you can read the live output of the updates here:
cat /tmp/cleanup_execution.log
Hope this helps Zorin Lite users keep their system fresh and clean effortlessly!
AI-assisted tutorial, please verify critical steps

