diff --git a/sync b/sync index d2c1f3a..d8f807c 100755 --- a/sync +++ b/sync @@ -77,11 +77,24 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then fi if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then - echo "there's a sync process running behind, please try again later.." - exit 1 -else + + cur_date=`date +%Y%m%d%H%M` + file_date=`cat "$PLANET_DIR/$LOCK_FILE"` + sub=$((cur_date - file_date)) + #if the difference is bigger than the 10 minutes interval of cron job, that means we have lock file that requires delete + if [ $sub -gt 15 ]; then + echo "Removing the lock file" >> "$LOG_DIR/$LOG_FILE" 2>&1 + rm -f "$PLANET_DIR/$LOCK_FILE" + else + echo "there's a sync process running behind, please try again later.." + exit 1 + fi +fi touch "$PLANET_DIR/$LOCK_FILE" + # lets add the runtime of the script to the lock file + echo "$(date +"%Y%m%d%H%M")" > "$PLANET_DIR/$LOCK_FILE" + cd "$PLANET_DIR" if (( $VERBOSE == 0 )); then @@ -97,7 +110,6 @@ else "$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini" echo "-----------------------------------------------------------" fi -fi # if ended successfully delete the lock file rm "$PLANET_DIR/$LOCK_FILE" diff --git a/sync-kisisel b/sync-kisisel index c66ea73..45b9c49 100755 --- a/sync-kisisel +++ b/sync-kisisel @@ -77,11 +77,23 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then fi if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then - echo "there's a sync process running behind, please try again later.." - exit 1 -else + cur_date=`date +%Y%m%d%H%M` + file_date=`cat "$PLANET_DIR/$LOCK_FILE"` + sub=$((cur_date - file_date)) + #if the difference is bigger than the 10 minutes interval of cron job, that means we have lock file that requires delete + if [ $sub -gt 15 ]; then + echo "Removing the lock file" >> "$LOG_DIR/$LOG_FILE" 2>&1 + rm -f "$PLANET_DIR/$LOCK_FILE" + else + echo "there's a sync process running behind, please try again later.." + exit 1 +fi + touch "$PLANET_DIR/$LOCK_FILE" + # lets add the runtime of the script to the lock file + echo "$(date +"%Y%m%d%H%M")" > "$PLANET_DIR/$LOCK_FILE" + cd "$PLANET_DIR" if (( $VERBOSE == 0 )); then diff --git a/sync-lkd b/sync-lkd index 6dde95b..9ce896c 100755 --- a/sync-lkd +++ b/sync-lkd @@ -77,10 +77,22 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then fi if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then - echo "there's a sync process running behind, please try again later.." - exit 1 -else + cur_date=`date +%Y%m%d%H%M` + file_date=`cat "$PLANET_DIR/$LOCK_FILE"` + sub=$((cur_date - file_date)) + #if the difference is bigger than the 10 minutes interval of cron job, that means we have lock file that requires delete + if [ $sub -gt 15 ]; then + echo "Removing the lock file" >> "$LOG_DIR/$LOG_FILE" 2>&1 + rm -f "$PLANET_DIR/$LOCK_FILE" + else + echo "there's a sync process running behind, please try again later.." + exit 1 +fi + touch "$PLANET_DIR/$LOCK_FILE" + + # lets add the runtime of the script to the lock file + echo "$(date +"%Y%m%d%H%M")" > "$PLANET_DIR/$LOCK_FILE" cd "$PLANET_DIR" diff --git a/sync-planet b/sync-planet index d3ea705..79e671e 100755 --- a/sync-planet +++ b/sync-planet @@ -77,10 +77,22 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then fi if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then - echo "there's a sync process running behind, please try again later.." - exit 1 -else + cur_date=`date +%Y%m%d%H%M` + file_date=`cat "$PLANET_DIR/$LOCK_FILE"` + sub=$((cur_date - file_date)) + #if the difference is bigger than the 10 minutes interval of cron job, that means we have lock file that requires delete + if [ $sub -gt 15 ]; then + echo "Removing the lock file" >> "$LOG_DIR/$LOG_FILE" 2>&1 + rm -f "$PLANET_DIR/$LOCK_FILE" + else + echo "there's a sync process running behind, please try again later.." + exit 1 +fi + touch "$PLANET_DIR/$LOCK_FILE" + + # lets add the runtime of the script to the lock file + echo "$(date +"%Y%m%d%H%M")" > "$PLANET_DIR/$LOCK_FILE" cd "$PLANET_DIR" diff --git a/sync-topluluk b/sync-topluluk index 210b8d1..b94f28e 100755 --- a/sync-topluluk +++ b/sync-topluluk @@ -77,10 +77,22 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then fi if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then - echo "there's a sync process running behind, please try again later.." - exit 1 -else + cur_date=`date +%Y%m%d%H%M` + file_date=`cat "$PLANET_DIR/$LOCK_FILE"` + sub=$((cur_date - file_date)) + #if the difference is bigger than the 10 minutes interval of cron job, that means we have lock file that requires delete + if [ $sub -gt 15 ]; then + echo "Removing the lock file" >> "$LOG_DIR/$LOG_FILE" 2>&1 + rm -f "$PLANET_DIR/$LOCK_FILE" + else + echo "there's a sync process running behind, please try again later.." + exit 1 +fi + touch "$PLANET_DIR/$LOCK_FILE" + + # lets add the runtime of the script to the lock file + echo "$(date +"%Y%m%d%H%M")" > "$PLANET_DIR/$LOCK_FILE" cd "$PLANET_DIR"