mod_security_logclean.sh 440 Bytes
Newer Older
1
#!/bin/bash
Simon Josi's avatar
Simon Josi committed
2

mh's avatar
mh committed
3
4
5
# clean up mod_security log directories that are within
# a certain age
[ -z $1 ] && echo "USAGE: $0 days_to_keep" && exit 1
mh's avatar
mh committed
6
7
8
9
10
11
for vhost in /var/www/vhosts/*/logs; do
  if ls $vhost/20* 1> /dev/null 2>&1; then
    tmpwatch -q ${1}d $vhost/20*
    find $vhost/20* -ignore_readdir_race -maxdepth 1 -mindepth 1 -type d -empty -delete
    find $vhost/20* -ignore_readdir_race -maxdepth 0 -mindepth 0 -type d -empty -delete
  fi
Simon Josi's avatar
Simon Josi committed
12
done