kamctl: usrloc command to delete older expired records from database table master
authorDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 14 Jun 2019 11:05:14 +0000 (13:05 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 14 Jun 2019 11:06:32 +0000 (13:06 +0200)
- kamctl ul dbclean [<secs>]
- if secs parameter is not given, the value 3600 is used

utils/kamctl/kamctl
utils/kamctl/kamctl.ctlbase

index a5f5180..cc92e0e 100755 (executable)
@@ -2717,6 +2717,18 @@ usrloc() {
                        fi
                        ;;
 
+               dbclean)
+                       require_dbengine
+                       KSR_CLEAN_VAL=3600
+                       if [ $# -eq 2 ] ; then
+                               KSR_CLEAN_VAL=$2
+                       fi
+                       QUERY="delete from $USRLOC_TABLE where expires < SUBDATE(NOW(), INTERVAL $KSR_CLEAN_VAL SECOND);"
+                       $DBCMD "$QUERY"
+
+                       exit $?
+                       ;;
+
                *)
                        usage_usrloc
                        exit 1
index 1fc6409..5215099 100644 (file)
@@ -71,6 +71,7 @@ cat <<EOF
  ul add <username> <uri> ............... introduce a permanent usrloc entry
  ul add <username> <uri> <expires> ..... introduce a temporary usrloc entry
  ul add <user> <uri> <expires> <path> .. introduce a temporary usrloc entry
+ ul dbclean [<secs>].................... remove older expired records from db table
 EOF
 }
 USAGE_FUNCTIONS="$USAGE_FUNCTIONS usage_usrloc"