Commit d67b24795dea4c3006064623c19317eb72387a8b

Authored by Fernando Ribeiro
1 parent 4a42d5c1f6

Added script to remove batch exports form Administration interface. It uses the …

…configuration of dspace to get the path ant time to live of the referred files and if the time passes it removes from the filesystem.
It should be automatic in dspace but it isn't working.
Showing 1 changed file with 28 additions and 0 deletions   Show diff stats
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 +
... ...