Skip to Content

qb clean - System Maintenance

Clean & Optimize

Free up memory, remove clutter, and maintain peak server performance

The qb clean functions offer a convenient and efficient way to maintain your server’s cleanliness and optimize its performance. Designed with simplicity and effectiveness in mind, these functions enable you to free up valuable memory, remove unnecessary clutter, and ensure a smooth and streamlined server operation.

CLI for host-level maintenance
Tip

The dashboard is the recommended surface for everyday app and user management. These qb clean utilities are host-level maintenance tasks suited to the CLI, automation, and scheduled cron jobs.


Quick Reference

CommandDescriptionAdmin Only
qb clean memory
Drop system memory cachesNo
qb clean rclone_log -u username
Clear rclone upload logsNo
qb clean qb_logs -u username
Truncate QuickBox and Nginx error logsYes (Level 9+)
qb clean system_logs -o [days] -u username
Remove old /var/log files (default: 7 days)Yes (Level 9+)
qb clean lock
Remove QuickBox and apt-dpkg locksNo
qb clean user_action_logs --days [days]
Delete user dashboard logs from database (default: 30)No
qb clean system_action_logs --days [days]
Delete system logs from database (default: 30)No

Available Commands

Clean Memory

Free up system memory by dropping caches:

bash
qb clean memory

What it does:

  • Executes echo 1 > /proc/sys/vm/drop_caches
  • Clears page cache, dentries, and inodes
  • Frees up RAM for better performance
  • Safe to run anytime (read-only data is dropped)

Technical details:

  • Does NOT affect dirty/modified data
  • Only drops clean cached data
  • No data loss occurs
  • RAM is freed immediately

When to use:

  • System is running slow
  • High memory usage detected
  • After installing/removing large applications
  • As part of regular maintenance
Regular Maintenance
Tip

Running qb clean memory periodically can help maintain optimal server performance, especially on systems with limited RAM.


Clean QuickBox System Logs

Truncate QuickBox and Nginx error logs (requires admin privileges):

bash
qb clean qb_logs -u username

Admin requirement:

  • User level 9 (admin) or 10 (super-admin) required
  • Permission check enforced by database

What it truncates:

  • /var/log/qb/quickbox.log - QuickBox actions log
  • /var/log/nginx/qbdash_error.log - Dashboard Nginx errors
  • /var/log/nginx/error.log - General Nginx errors

When to use:

  • After resolving dashboard errors
  • Logs growing too large
  • Before generating support logs
  • Troubleshooting UI issues
Admin Only
Warning

This command requires admin privileges (user level 9+). Standard users will be denied with “You do not have permission to run this command.”


Remove Old System Log Files

Delete logs and compressed archives in /var/log (requires admin privileges):

bash
# Use default 7-day retention
qb clean system_logs -u username
 
# Custom retention period (3 days)
qb clean system_logs -o 3 -u username

Admin requirement:

  • User level 9 (admin) or 10 (super-admin) required
  • Permission check enforced by database

Options:

  • -o [days] - Retention period in days (default: 7 if not specified)
  • -u [username] - Username (required for permission check)

What gets removed from /var/log:

  • All files (-type f) older than specified days
  • Compressed archives: *.gz
  • Old log files: *.old
  • Numbered log files: *.[0-9], *.[0-9].log

Find commands executed:

bash
find /var/log -type f -mtime +[days] -exec rm -f {} \;
find /var/log -type f -mtime +[days] -name "*.gz" -exec rm -f {} \;
find /var/log -type f -mtime +[days] -name "*.old" -exec rm -f {} \;
find /var/log -type f -mtime +[days] -name "*.[0-9]" -exec rm -f {} \;
find /var/log -type f -mtime +[days] -name "*.[0-9].log" -exec rm -f {} \;
Admin Only + Permanent Deletion
Warning

This command requires admin privileges (level 9+) and permanently deletes files. Review or backup logs before cleaning.


Clean Rclone Upload Log

Clear rclone upload log file for a specific user:

bash
qb clean rclone_log -u username

What it does:

  • Empties /home/username/rclone/move.log file
  • Clears rclone upload operation history
  • Preserves file (truncates to empty, doesn’t delete)

Prerequisites:

  • File /home/username/rclone/move.log must exist
  • User must have rclone configured

Error handling:

  • Returns error code 2 if username not specified
  • Returns error code 3 if rclone log file doesn’t exist

When to use:

  • Rclone logs growing too large
  • After bulk upload operations
  • Troubleshooting rclone issues
  • Disk space cleanup
Rclone Users
Tip

If you use rclone heavily for cloud uploads, consider cleaning logs weekly to prevent excessive disk usage.


Clean Locks

Remove QuickBox software and apt-dpkg locks that may prevent installations:

bash
qb clean lock

What it does:

  • Runs quickbox::apt::update to update package lists
  • Calls quickbox::lock::cleanup function
  • Removes QuickBox installation locks
  • Removes apt-dpkg locks
  • Clears package manager locks
  • Stops stale installation processes

When to use this:

Symptoms

  • "Unable to acquire lock"
  • "dpkg lock is held by another process"
  • "Installation already in progress"
  • "Could not get lock /var/lib/dpkg/lock"

Resolution

  • Stops any stale processes
  • Removes lock files safely
  • Configures pending packages
  • Allows new installations
Use When Needed
Caution

Only use this command when you encounter lock errors. Don’t run it unnecessarily as it forcibly terminates package operations.


Clean User Action Logs

Delete user dashboard logs from database older than specified days:

bash
# Delete logs older than 30 days (default)
qb clean user_action_logs
 
# Custom retention period
qb clean user_action_logs --days 14
qb clean user_action_logs -d 7
 
# Cron mode (for automated cleanup)
qb clean user_action_logs --cron

What it does:

  • Deletes log_type = 'dashboard' entries from system_log table
  • Uses UNIX timestamp comparison for efficiency
  • Default retention: 30 days
  • Logs the cleanup operation itself

Options:

  • --days or -d - Number of days to retain (default: 30)
  • --cron - Cron mode (changes log source to ‘cron’)

Database operation:

sql
DELETE FROM system_log
WHERE log_type = 'dashboard'
AND timestamp <= [unix_timestamp_threshold];

When to use:

  • Database growing too large
  • Dashboard performance degrading
  • Regular maintenance automation
  • Privacy compliance (data retention policies)

Clean System Action Logs

Delete system logs from database older than specified days:

bash
# Delete logs older than 30 days (default)
qb clean system_action_logs
 
# Custom retention period
qb clean system_action_logs --days 14
qb clean system_action_logs -d 7
 
# Cron mode (for automated cleanup)
qb clean system_action_logs --cron

What it does:

  • Deletes log_type = 'system' entries from system_log table
  • Uses formatted date comparison
  • Default retention: 30 days
  • Logs the cleanup operation itself

Options:

  • --days or -d - Number of days to retain (default: 30)
  • --cron - Cron mode (changes log source to ‘cron’)

Database operation:

sql
DELETE FROM system_log
WHERE log_type = 'system'
AND timestamp <= 'YYYY-MM-DD HH:MM:SS';

When to use:

  • Database growing too large
  • Improve database query performance
  • Regular maintenance automation
  • Compliance with data retention policies

Common Workflows

Regular Maintenance Routine

Weekly cleanup routine for optimal performance:

bash
# 1. Clean system memory
qb clean memory
 
# 2. Remove old system logs (keep last 7 days - requires admin)
qb clean system_logs -u yourusername
 
# 3. Clean rclone logs (if using rclone)
qb clean rclone_log -u yourusername
 
# 4. Clean database logs (optional - keep last 30 days)
qb clean user_action_logs --days 30
qb clean system_action_logs --days 30

Troubleshooting Installation Issues

When installations fail due to locks:

bash
# 1. Clean locks first
qb clean lock
 
# 2. Try your installation again
qb install sonarr -u yourusername

Free Up Disk Space

When running low on disk space:

bash
# 1. Remove old logs (aggressive 3-day retention - requires admin)
qb clean system_logs -o 3 -u yourusername
 
# 2. Clean rclone logs
qb clean rclone_log -u yourusername
 
# 3. Clean database logs (aggressive 7-day retention)
qb clean user_action_logs --days 7
qb clean system_action_logs --days 7
 
# 4. Clean memory caches
qb clean memory
 
# 5. Check disk usage
df -h
du -sh /var/log

Dashboard Issues Resolution

When dashboard is slow or showing errors:

bash
# 1. Clean QB system logs (requires admin)
qb clean qb_logs -u yourusername
 
# 2. Clean memory
qb clean memory
 
# 3. Check if services are running
systemctl status nginx
systemctl status php*-fpm

Best Practices

Do

  • Run clean memory when system is slow
  • Clean logs weekly for maintenance
  • Use shorter retention for low-disk servers
  • Clean locks when encountering install errors
  • Clean rclone logs after bulk transfers
  • Backup important logs before cleaning

Don't

  • Clean logs while troubleshooting active issues
  • Run clean lock during active installations
  • Use very short retention (< 3 days) periods
  • Clean memory excessively (once daily is enough)
  • Delete logs needed for support tickets
  • Run cleanup during peak usage times

Automation

Create Automated Cleanup Script

You can automate regular cleanup tasks with a cron job:

bash
#!/bin/bash
# /root/scripts/weekly-cleanup.sh
 
echo "Starting weekly cleanup - $(date)"
 
# Clean memory
qb clean memory
 
# Clean logs for all users (adjust usernames)
for user in user1 user2 user3; do
  echo "Cleaning logs for $user"
  qb clean system_logs -o 7 -u $user          # Requires admin
  qb clean rclone_log -u $user
done
 
# Clean database logs (30-day retention)
qb clean user_action_logs --days 30 --cron
qb clean system_action_logs --days 30 --cron
 
echo "Cleanup completed - $(date)"

Set up weekly cron job:

bash
# Make script executable
chmod +x /root/scripts/weekly-cleanup.sh
 
# Add to crontab (runs every Sunday at 3 AM)
echo "0 3 * * 0 /root/scripts/weekly-cleanup.sh >> /var/log/weekly-cleanup.log 2>&1" | crontab -
Admin Privileges Required
Note

This script requires admin privileges since it runs qb clean system_logs and qb clean qb_logs. Run as root or with sudo.


Disk Space Management

Check Disk Usage Before Cleaning

bash
# Check overall disk usage
df -h
 
# Check log directory size
du -sh /var/log
 
# Check user home directories
du -sh /home/*
 
# Find largest log files
find /var/log -type f -exec du -h {} + | sort -rh | head -20

After Cleaning

bash
# Verify disk space freed
df -h
 
# Check log directory after cleanup
du -sh /var/log

Troubleshooting

”Permission Denied” Errors

bash
# Clean commands require root/sudo access
sudo qb clean memory
 
# Or switch to root
sudo -i
qb clean memory

Lock Clean Not Working

bash
# If lock clean fails, manually investigate
ps aux | grep -E 'apt|dpkg'
 
# Kill specific processes if needed (use carefully)
kill -9 [PID]
 
# Then try again
qb clean lock

Logs Still Large After Cleaning

bash
# Check for active log writers
lsof /var/log/*
 
# Check journal size
journalctl --disk-usage
 
# Clean systemd journal
journalctl --vacuum-time=7d


Need Help?

Join the Community

Media server operators sharing configs, getting support, and shaping the future of QuickBox Pro.

  • Dedicated Support
  • Feature Previews
  • Community Configs
  • Active Discussions
Join Discord Server
Last updated on