|
1
|
|
|
#! /usr/bin/env php |
|
2
|
|
|
<?php |
|
3
|
|
|
// This file is part of BOINC. |
|
4
|
|
|
// http://boinc.berkeley.edu |
|
5
|
|
|
// Copyright (C) 2008 University of California |
|
6
|
|
|
// |
|
7
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
|
8
|
|
|
// under the terms of the GNU Lesser General Public License |
|
9
|
|
|
// as published by the Free Software Foundation, |
|
10
|
|
|
// either version 3 of the License, or (at your option) any later version. |
|
11
|
|
|
// |
|
12
|
|
|
// BOINC is distributed in the hope that it will be useful, |
|
13
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
// See the GNU Lesser General Public License for more details. |
|
16
|
|
|
// |
|
17
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
|
18
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
|
|
20
|
|
|
// delete files from the web cache until free-space criteria are met |
|
21
|
|
|
|
|
22
|
|
|
$cli_only = true; |
|
23
|
|
|
require_once("../inc/cache.inc"); |
|
24
|
|
|
require_once("../inc/util_ops.inc"); |
|
25
|
|
|
|
|
26
|
|
|
set_time_limit(0); |
|
27
|
|
|
|
|
28
|
|
|
function main(){ |
|
29
|
|
|
echo "------- Starting at ".time_str(time())."-------\n"; |
|
30
|
|
|
|
|
31
|
|
|
echo sprintf("max cache usage: %s\n", size_string(MAX_CACHE_USAGE)); |
|
32
|
|
|
$too_old = 86400*7; |
|
33
|
|
|
while (1) { |
|
34
|
|
|
$u = disk_usage("../cache"); |
|
35
|
|
|
echo sprintf("cache usage: %s\n", size_string($u)); |
|
36
|
|
|
if ($u < MAX_CACHE_USAGE) { |
|
37
|
|
|
echo "criteria met; quitting\n"; |
|
38
|
|
|
break; |
|
39
|
|
|
} |
|
40
|
|
|
echo sprintf("deleting files older than %s\n", time_diff($too_old)); |
|
41
|
|
|
clean_cache($too_old, "../cache"); |
|
42
|
|
|
$too_old /= 2; |
|
43
|
|
|
if ($too_old < 60) { |
|
44
|
|
|
break; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
echo "------- Finished at ".time_str(time())."-------\n"; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
main(); |
|
51
|
|
|
?> |
|
52
|
|
|
|