-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed SERIOUS bug in trim-cache service
- Loading branch information
1 parent
4ee2cef
commit 4a51ba3
Showing
2 changed files
with
7 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
. /srv/lib/conf | ||
load_conf trim-cache max_disk_usage min_disk_usage | ||
|
||
cd /srv/cache | ||
disk_usage=($(du --block-size=1K --summarize)) | ||
disk_usage=($(du /srv/cache --block-size=1K --summarize)) | ||
(( disk_usage < max_disk_usage )) && exit | ||
|
||
find -mindepth 2 -printf '%C@ %k\n' | sort --numeric-sort | while read ctime blocks; do | ||
find /srv/cache -mindepth 2 -printf '%C@ %k\n' | sort --numeric-sort | while read ctime blocks; do | ||
(( (disk_usage -= blocks) > min_disk_usage )) && continue | ||
find -mindepth 2 -not -newerct @$ctime -delete | ||
find /srv/cache -mindepth 2 -not -newerct @$ctime -delete | ||
exit | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ Description=Trim TIO's output cache | |
[Service] | ||
Type=oneshot | ||
User=apache | ||
Group=apache | ||
ExecStart=/srv/bin/trim-cache |