51 lines
1.2 KiB
Bash
51 lines
1.2 KiB
Bash
#!/bin/bash
|
|
#find only directories older then 10 days
|
|
|
|
#this will tar and remove
|
|
#tar -cvf /home/roy/Desktop/test/some_dir.tgz /home/roy/Desktop/test/some_dir --remove-files
|
|
|
|
while test $# -gt 0; do
|
|
case "$1" in
|
|
-h|--help)
|
|
echo "$package - attempt to capture frames"
|
|
echo " "
|
|
echo "$package [options] application [arguments]"
|
|
echo " "
|
|
echo "options:"
|
|
echo "-h, --help show brief help"
|
|
echo "--days=<1-n> specify an action to use"
|
|
echo "-o, --output-dir=DIR specify a directory to store output in"
|
|
exit 0
|
|
;;
|
|
-a)
|
|
shift
|
|
DIR_NAME=($(find /var/log -maxdepth 1 -type d -mtime +10))
|
|
if test $# -gt 0; then
|
|
export PROCESS=$1
|
|
else
|
|
for dir in "${DIR_NAME[@]}"
|
|
do
|
|
echo "tar -czPf $dir.tar.gz $dir --remove-files"
|
|
done
|
|
exit 1
|
|
fi
|
|
shift
|
|
;;
|
|
--days*)
|
|
DIR_NAME=($(find /var/log/ -maxdepth 1 -type d -mtime +$2))
|
|
if test $# -gt 0; then
|
|
export PROCESS=$1
|
|
else
|
|
for dir in "${DIR_NAME[@]}"
|
|
do
|
|
echo "tar -czPf $dir.tar.gz $dir --remove-files"
|
|
done
|
|
exit 1
|
|
|
|
shift
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
done |