diff options
author | jeff <jeff> | 2009-07-17 14:58:22 +0000 |
---|---|---|
committer | jeff <jeff> | 2009-07-17 14:58:22 +0000 |
commit | 4bfca794e2bd03379d11b9efe437676323e7eb31 (patch) | |
tree | 8d1101ca7e29de05fb704d6e863619aa0d2605d1 /bin | |
parent | e300f21783a78b911256e04cd7af86b1d57eeb04 (diff) |
add mutex and commit changes found on installed system
Diffstat (limited to 'bin')
-rw-r--r-- | bin/billco-upload | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/billco-upload b/bin/billco-upload index ce4a43d5f..3a02ec8bb 100644 --- a/bin/billco-upload +++ b/bin/billco-upload @@ -1,11 +1,26 @@ #!/bin/sh -AGENTNUMS="1 2 3" +AGENTNUMS="1 2 3 5 8 9 10" date=`date +"%Y%m%d"` dir="/usr/local/etc/freeside/export.DBI:Pg:dbname=freeside/cust_bill" +lock=".billco-upload.lock" cd "$dir" +failed_mutex() +{ + echo "billco-upload already running; exiting" + exit 1 +} + +#acquire mutex +[ -f $lock ] && { + failed_mutex +} || { + echo $$ > $lock + [ $(cat $lock 2>/dev/null) -eq $$ ] || failed_mutex +} + for AGENTNUM in $AGENTNUMS; do for a in header detail; do @@ -14,7 +29,12 @@ for AGENTNUM in $AGENTNUMS; do zip agentnum$AGENTNUM-$date.zip agentnum$AGENTNUM-$date-header.csv agentnum$AGENTNUM-$date-detail.csv +# Remove if trying to find problems with billco upload files + rm *$AGENTNUM-$date*.csv + echo $dir/agentnum$AGENTNUM-$date.zip done +#release mutex +rm -f $lock |