Terminal Scripts - Bytesized Hosting Wiki
Just a collection of useful scripts
To check a folder and delete all files not accessed in X days
{PATH} = your path to the folder you want to monitor.
{TIME} = time in days since last access
#!/bin/bash
find {PATH} -mindepth 1 -atime +{TIME} -delete
This will find all files and folders within {PATH}, and delete all files and folders not accessed within {TIME} days.
To do a trial run (recommended!) just remove the -delete from the end. If you'd like to keep one more depth of folders change mindepth to 2.
Last Author | Contributors | Versions | Last update |
---|---|---|---|
Pete | None | 6 | Mon, 06 Jan 2025 07:28:35 +0100 |