Shell Script to remove files recursively from a folder
Shell Script to remove files recursively from a folder with 10 minutes each:
When we were running a Load test or stability test, one of the transaction creates files in a directory. These files need to be deleted when ran for long runs.
In Linux:
fdir="<path>/App_domain/attachments/lit/*"
while [ true ]
do
find $fdir -cmin +10 -type f -exec rm -rf {} \;
sleep 500
done
when tried the above on solaris, it failed as -cmin is not supported in Solaris. Only options supported are -atime, -ctime and -mtime. but these works on hours and not on minutes.
Modified the script to run in solaris:
fdir="<path>/App_domain/attachments/lit/*"
while [ true ]
do
touch somefile
sleep 5
find $fdir ! -newer somefile -exec rm -rf {} \;
sleep 500
done
When we were running a Load test or stability test, one of the transaction creates files in a directory. These files need to be deleted when ran for long runs.
In Linux:
fdir="<path>/App_domain/attachments/lit/*"
while [ true ]
do
find $fdir -cmin +10 -type f -exec rm -rf {} \;
sleep 500
done
when tried the above on solaris, it failed as -cmin is not supported in Solaris. Only options supported are -atime, -ctime and -mtime. but these works on hours and not on minutes.
Modified the script to run in solaris:
fdir="<path>/App_domain/attachments/lit/*"
while [ true ]
do
touch somefile
sleep 5
find $fdir ! -newer somefile -exec rm -rf {} \;
sleep 500
done
Comments
Post a Comment