From 9eb1cd7b9403533c4b60ecfbbbf00a08c211059a Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Aug 2010 15:03:27 +0200 Subject: Move common function to db-functions db-functions now sets an individual $WORKDIR and implements trap functinos that remove locks on exit or error. There are new functions to lock and unlock the running script. misc-scripts/ftpdir-cleanup was renamed to ftpdir-cleanup-repo as the cron-job had the same name. Script names have to be unique when using db-functions. --- cron-jobs/ftpdir-cleanup | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'cron-jobs/ftpdir-cleanup') diff --git a/cron-jobs/ftpdir-cleanup b/cron-jobs/ftpdir-cleanup index 546afd9..f5e401a 100755 --- a/cron-jobs/ftpdir-cleanup +++ b/cron-jobs/ftpdir-cleanup @@ -5,34 +5,14 @@ repos="$(get_repos_for_host)" -LOCKFILE="/tmp/.ftpdircleanup.lock" - -cleanup () { - rm -f "$LOCKFILE" - exit 0 -} - -ctrl_c() { - cleanup -} - -if [ -f "$LOCKFILE" ]; then - owner="$(/usr/bin/stat -c %U $LOCKFILE)" - echo "error: ftp cleanup is already in progress (started by $owner)" - exit 1 -fi - -trap cleanup 0 -trap ctrl_c 2 - -/bin/touch "$LOCKFILE" +script_lock #adjust the nice level to run at a lower priority /usr/bin/renice +10 -p $$ > /dev/null repopaths='' for repo in $repos; do - $(dirname $0)/../misc-scripts/ftpdir-cleanup $repo + $(dirname $0)/../misc-scripts/ftpdir-cleanup-repo $repo repopaths="${repopaths} ${FTP_BASE}/${repo}/os/" done @@ -60,4 +40,4 @@ if [ -n "$to_cleanup" ]; then mv $to_cleanup "$CLEANUP_DESTDIR" fi -cleanup +script_unlock -- cgit v1.2.3-24-g4f1b