From 8c7d6dc4893522e1f8c0cbe4e4d12f31b9226b9e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 16 Dec 2008 23:59:04 +0000 Subject: [PATCH] - web: added ops/autolock.php script; locks threads not modified in last 60 days svn path=/trunk/boinc/; revision=16704 --- checkin_notes | 10 ++++++++++ html/inc/db_conn.inc | 4 ++++ html/ops/autolock.php | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100755 html/ops/autolock.php diff --git a/checkin_notes b/checkin_notes index e3d3b74a4e..efb249d9c3 100644 --- a/checkin_notes +++ b/checkin_notes @@ -10170,3 +10170,13 @@ David 16 Dec 2008 html/inc text_transform.inc + +David 16 Dec 2008 + - web: added ops/autolock.php script; + locks threads not modified in last 60 days + + html/ + inc/ + db_conn.inc + ops/ + autolock.php diff --git a/html/inc/db_conn.inc b/html/inc/db_conn.inc index a8f11dd9fd..1392d3f308 100644 --- a/html/inc/db_conn.inc +++ b/html/inc/db_conn.inc @@ -50,6 +50,10 @@ class DbConn { return $ret; } + function affected_rows() { + return mysql_affected_rows($this->db_conn); + } + function lookup_fields($table, $classname, $fields, $clause) { $query = "select $fields from DBNAME.$table where $clause"; $result = $this->do_query($query); diff --git a/html/ops/autolock.php b/html/ops/autolock.php new file mode 100755 index 0000000000..7eeb68c60c --- /dev/null +++ b/html/ops/autolock.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +. + +// lock all threads older than N days + +require_once("../inc/boinc_db.inc"); +require_once("../inc/util.inc"); + +$max_age_days = 60; // lock threads older than this + +$t = time_str(time()); +echo "starting at $t\n"; +$t = time() - $max_age_days*86400; +$db = BoincDb::get(); +if (!$db) die("can't open DB\n"); +$db->do_query("update DBNAME.thread set locked=1 where timestamp<$t and locked=0 and sticky=0"); +$n = $db->affected_rows(); +$t = time_str(time()); +echo "finished at $t; locked $n threads\n"; +?>