[scripts] add cleanup_pkgcache_locked.sh, move locking from crontab

This commit is contained in:
Fabio Erculiani 2012-09-01 13:26:27 +02:00
parent e4cef07575
commit 7d545ee026
2 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,6 @@
# Path to molecules.git dir # Path to molecules.git dir
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}" SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
export SABAYON_MOLECULE_HOME
DIR="${SABAYON_MOLECULE_HOME}/pkgcache" DIR="${SABAYON_MOLECULE_HOME}/pkgcache"
find "${DIR}" -atime +30 -type f -delete find "${DIR}" -atime +30 -type f -delete

View File

@ -0,0 +1,14 @@
# Path to molecules.git dir
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
. "${SABAYON_MOLECULE_HOME}/scripts/iso_build.include"
(
flock --timeout 7200 -x 9
if [ "${?}" != "0" ]; then
echo "[cleanup] cannot acquire lock, stale process holding it?" >&2
exit 1
fi
"${SABAYON_MOLECULE_HOME}/scripts/cleanup_pkgcache.sh"
) 9> "${ISO_BUILD_LOCK}"
exit ${?}