Quota scripts - kennyHH/AWS GitHub Wiki

This project includes two main scripts for managing large files in user directories:

  1. scan_and_move_large_files.sh
  2. clear_tmp_folder.sh

scan_and_move_large_files.sh

Purpose

This script scans specified directories for large files and moves them to a temporary location.

How it works

  1. Searches through /home/webdev and /home/compsc directories recursively.
  2. Identifies files larger than a specified size (default: 50MB).
  3. Moves large files to /tmp/<username>/ directories.
  4. Logs actions in /var/log/large_file_moves.log.

Configuration

Parameter Description
MAX_FILE_SIZE Set the threshold for large files (e.g., 50M for 50 megabytes)
SEARCH_DIRS Array of directories to scan

clear_tmp_folder.sh

Purpose

This script cleans up the temporary folders created by scan_and_move_large_files.sh.

How it works

  1. Searches for directories in /tmp that start with "HN".
  2. Removes these directories and their contents.
  3. Counts and logs the number of items removed.
  4. Logs actions in /var/log/tmp_cleanup.log.

Automation

⚠️ Important: This can be edited before deployment by modifying dockerfile in lines 56-57.

Both scripts are automated using cron jobs and can be modified on the live machine:

  1. Edit the crontab:

    crontab -e
  2. Edit the following lines:

    0 0 * * * /root/scan_and_move_large_files.sh
    0 0 * * 0 /root/clear_tmp_folder.sh

    Note: This setup runs the scan script daily and the cleanup script every Sunday at midnight.


Logs

Log File Description
/var/log/large_file_moves.log Scan and move log
/var/log/tmp_cleanup.log Cleanup log

Tip: Review these logs regularly to monitor the scripts' performance and any issues.

⚠️ **GitHub.com Fallback** ⚠️