Commit d88830cb25f89f3dff2d3af9f9917acf019255f4

Authored by Fernando Ribeiro
1 parent 3322ea16d3

Add script to verify if statistics is running

dspace/bin/RCAAP-remove_export_files.sh
... ... @@ -0,0 +1,28 @@
  1 +#!/bin/bash
  2 +
  3 +#First get the script dir
  4 +cd `dirname $0`
  5 +DIR_NAME=$(pwd)
  6 +
  7 +#Second read the dspace.cfg file and retrieve item_export_time value
  8 +##SET PATH TO DSPACE_CFG
  9 +cd $DIR_NAME
  10 +cd ../config/
  11 +#pwd
  12 +
  13 +#PATH_OF_FILES_TO_REMOVE=`cat dspace.cfg | grep "org.dspace.app.itemexport.download.dir" | cut -d" " -f3`
  14 +#TIME_TO_LIVE_HOURS=`cat dspace.cfg | grep "org.dspace.app.itemexport.life.span.hours" | cut -d" " -f3`
  15 +
  16 +#THIS IS A BETTER OPTION
  17 +PATH_OF_FILES_TO_REMOVE=`cat dspace.cfg | grep "org.dspace.app.itemexport.download.dir" | cut -d"=" -f2 | sed -e 's/^[[:space:]]*//'`
  18 +TIME_TO_LIVE_HOURS=`cat dspace.cfg | grep "org.dspace.app.itemexport.life.span.hours" | cut -d"=" -f2 | sed -e 's/^[[:space:]]*//'`
  19 +
  20 +cd $PATH_OF_FILES_TO_REMOVE
  21 +
  22 +#TIME WILL BE IN MINUTES BUT IS DEFINED IN HOURS IN DSOACE.CFG
  23 +del_time_in_minutes=$((60 * $TIME_TO_LIVE_HOURS))
  24 +
  25 +#delete files that match criteria
  26 +find $PATH_OF_FILES_TO_REMOVE -maxdepth 2 -mmin +$del_time_in_minutes -type f -name "*.zip" -exec rm -f {} \;
  27 +
  28 +
... ...
dspace/bin/RCAAP-verify-aggregation_stats.sh
... ... @@ -0,0 +1,57 @@
  1 +#!/bin/bash
  2 +
  3 +#It should be obtained from dspace.cfg -> dbschema and user
  4 +user=dspace
  5 +db=dspace
  6 +
  7 +
  8 +#Verify if it's aggregating in the processes
  9 +output=`ps aux | grep aggregate | grep -v grep`
  10 +#echo $output
  11 +set -- $output
  12 +pid=$2
  13 +
  14 +#Ok, possibly is running a aggregate process
  15 +if [[ "$pid" =~ ^[0-9]+$ ]];
  16 +then
  17 + exit
  18 +fi;
  19 +
  20 +
  21 +#Verify if there is a control variable in stats.contol
  22 +#We only want the value - These are separated by \n, so we only need the thir value
  23 +aggdate=$(psql -U $user $db<<<"SELECT agg_end FROM stats.control" | cut -d $'\n' -f3)
  24 +
  25 +#Verify if is date or no date is present
  26 +#Stupid verification but it will do
  27 +if [[ $aggdate -eq "agg_end" ]];
  28 +then
  29 + exit
  30 +fi
  31 +
  32 +#echo "agg_end $aggdate"
  33 +
  34 +#Transform the date
  35 +aggdate=$(date -d "$aggdate" +"%Y%m%d")
  36 +
  37 +#Add 4 days - We update the table if already four days have passed and no schange in db is seen
  38 +newdate=$(date -d "$aggdate + 4 days" +"%Y%m%d")
  39 +
  40 +#Get actual date
  41 +today=$(date +"%Y%m%d")
  42 +
  43 +#echo "newdate $newdate"
  44 +#echo "today $today"
  45 +
  46 +
  47 +#Verify if the actual date is 4 days more than the date of agg_end
  48 +if [[ "$newdate" > "$today" ]];
  49 +then
  50 + exit
  51 +fi
  52 +
  53 +#Update Stats control
  54 +psql -U $user $db<<<"update stats.control set agg_start= null, agg_end = null;"
  55 +
  56 +
  57 +
... ...
dspace/bin/RCAAP_remove_export_files.sh
... ... @@ -1,28 +0,0 @@
1   -#!/bin/bash
2   -
3   -#First get the script dir
4   -cd `dirname $0`
5   -DIR_NAME=$(pwd)
6   -
7   -#Second read the dspace.cfg file and retrieve item_export_time value
8   -##SET PATH TO DSPACE_CFG
9   -cd $DIR_NAME
10   -cd ../config/
11   -#pwd
12   -
13   -#PATH_OF_FILES_TO_REMOVE=`cat dspace.cfg | grep "org.dspace.app.itemexport.download.dir" | cut -d" " -f3`
14   -#TIME_TO_LIVE_HOURS=`cat dspace.cfg | grep "org.dspace.app.itemexport.life.span.hours" | cut -d" " -f3`
15   -
16   -#THIS IS A BETTER OPTION
17   -PATH_OF_FILES_TO_REMOVE=`cat dspace.cfg | grep "org.dspace.app.itemexport.download.dir" | cut -d"=" -f2 | sed -e 's/^[[:space:]]*//'`
18   -TIME_TO_LIVE_HOURS=`cat dspace.cfg | grep "org.dspace.app.itemexport.life.span.hours" | cut -d"=" -f2 | sed -e 's/^[[:space:]]*//'`
19   -
20   -cd $PATH_OF_FILES_TO_REMOVE
21   -
22   -#TIME WILL BE IN MINUTES BUT IS DEFINED IN HOURS IN DSOACE.CFG
23   -del_time_in_minutes=$((60 * $TIME_TO_LIVE_HOURS))
24   -
25   -#delete files that match criteria
26   -find $PATH_OF_FILES_TO_REMOVE -maxdepth 2 -mmin +$del_time_in_minutes -type f -name "*.zip" -exec rm -f {} \;
27   -
28   -