Last active
December 7, 2017 12:53
-
-
Save gustavonovaes/89b6371a3ec51a31f3fb4b36197aac80 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# cron script to otimize space on file sharing server | |
# | |
# Written by Gustavo Novaes <[email protected]> for Mercantil Real | |
search_path=/mnt/samba | |
find $search_path -iname '*.csv' -or -iname '*.txt' -or -iname '*.mfd' | while IFS= read -r f; do | |
size=$(stat -c%s "$f") | |
size=`echo "$size / 1024 / 1024" | bc` | |
if [ "$size" -gt "2" ] && [ ! -f "${f%.*}.zip" ]; then | |
zip "${f%.*}.zip" "$f" | |
rm -f $f | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment