Quota scripts - kennyHH/AWS GitHub Wiki
This project includes two main scripts for managing large files in user directories:
scan_and_move_large_files.sh
clear_tmp_folder.sh
This script scans specified directories for large files and moves them to a temporary location.
- Searches through
/home/webdev
and/home/compsc
directories recursively. - Identifies files larger than a specified size (default: 50MB).
- Moves large files to
/tmp/<username>/
directories. - Logs actions in
/var/log/large_file_moves.log
.
Parameter | Description |
---|---|
MAX_FILE_SIZE |
Set the threshold for large files (e.g., 50M for 50 megabytes) |
SEARCH_DIRS |
Array of directories to scan |
This script cleans up the temporary folders created by scan_and_move_large_files.sh
.
- Searches for directories in
/tmp
that start with "HN". - Removes these directories and their contents.
- Counts and logs the number of items removed.
- Logs actions in
/var/log/tmp_cleanup.log
.
dockerfile
in lines 56-57.
Both scripts are automated using cron jobs and can be modified on the live machine:
-
Edit the crontab:
crontab -e
-
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.
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.