File: cron.daily

package info (click to toggle)
libapache-gallery-perl 1.0.2-4.1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 612 kB
  • ctags: 22
  • sloc: perl: 1,240; sh: 21; makefile: 15
file content (24 lines) | stat: -rw-r--r-- 672 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
#
# libapache-gallery-perl cleanup
# Remove all files in $cachedir that have not been accessed in a week,
# then remove empty directories.  Run as user $user.

set -e

cachedir="/var/cache/www"
user="www-data"

if [ -d "$cachedir" ]; then
    # remove old files
    start-stop-daemon --start --pidfile /dev/null --startas /bin/sh \
	--oknodo --chuid "$user" -- -c \
	"find '$cachedir' -type f -atime +6 -delete"
    # remove empty directories
    start-stop-daemon --start --pidfile /dev/null --startas /bin/sh \
	--oknodo --chuid "$user" -- -c \
	"find '$cachedir' -mindepth 1 -depth -type d -print0 | \
	 xargs -r0 rmdir --ignore-fail-on-non-empty"
fi

exit 0