Created
August 3, 2017 06:32
-
-
Save pradeepbishnoi/563ce182fc697f997371b7e98d84ef2f to your computer and use it in GitHub Desktop.
Clean up the folder which are older than X days from today date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Clean up the folder which are older than X days from today date. | |
| # Number value which specify how many days old | |
| NUM_OF_DAYS=3 | |
| # Depth which the folder should be iterated | |
| MAX_DEPTH=2 | |
| cleanup_folder() { | |
| # Pass the folder name as argument | |
| echo -e "Cleaning up the folder " $1 | |
| folder_path=$1 | |
| find $folder_path -maxdepth $MAX_DEPTH -type d -ctime +$NUM_OF_DAYS -exec ls -ltr {} \; | |
| } | |
| cleanup_folder /my/folder/path | |
| MAX_DEPTH=1 | |
| cleanup_folder /my/other/folder/path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment