Keep the runtime of the snyc script at the lock file and compare whether the passed time is above 15 minutes if so remove the lock file
This commit is contained in:
parent
2fec8c3202
commit
f701d0cdf5
20
sync
20
sync
|
@ -77,11 +77,24 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
||||||
echo "there's a sync process running behind, please try again later.."
|
|
||||||
exit 1
|
cur_date=`date +%Y%m%d%H%M`
|
||||||
else
|
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"
|
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"
|
cd "$PLANET_DIR"
|
||||||
|
|
||||||
if (( $VERBOSE == 0 )); then
|
if (( $VERBOSE == 0 )); then
|
||||||
|
@ -97,7 +110,6 @@ else
|
||||||
"$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini"
|
"$PLANET_DIR/planet.py" "$PLANET_DIR/gezegen/config.ini"
|
||||||
echo "-----------------------------------------------------------"
|
echo "-----------------------------------------------------------"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# if ended successfully delete the lock file
|
# if ended successfully delete the lock file
|
||||||
rm "$PLANET_DIR/$LOCK_FILE"
|
rm "$PLANET_DIR/$LOCK_FILE"
|
||||||
|
|
18
sync-kisisel
18
sync-kisisel
|
@ -77,11 +77,23 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
||||||
echo "there's a sync process running behind, please try again later.."
|
cur_date=`date +%Y%m%d%H%M`
|
||||||
exit 1
|
file_date=`cat "$PLANET_DIR/$LOCK_FILE"`
|
||||||
else
|
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"
|
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"
|
cd "$PLANET_DIR"
|
||||||
|
|
||||||
if (( $VERBOSE == 0 )); then
|
if (( $VERBOSE == 0 )); then
|
||||||
|
|
18
sync-lkd
18
sync-lkd
|
@ -77,11 +77,23 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
||||||
echo "there's a sync process running behind, please try again later.."
|
cur_date=`date +%Y%m%d%H%M`
|
||||||
exit 1
|
file_date=`cat "$PLANET_DIR/$LOCK_FILE"`
|
||||||
else
|
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"
|
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"
|
cd "$PLANET_DIR"
|
||||||
|
|
||||||
if (( $VERBOSE == 0 )); then
|
if (( $VERBOSE == 0 )); then
|
||||||
|
|
18
sync-planet
18
sync-planet
|
@ -77,11 +77,23 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
||||||
echo "there's a sync process running behind, please try again later.."
|
cur_date=`date +%Y%m%d%H%M`
|
||||||
exit 1
|
file_date=`cat "$PLANET_DIR/$LOCK_FILE"`
|
||||||
else
|
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"
|
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"
|
cd "$PLANET_DIR"
|
||||||
|
|
||||||
if (( $VERBOSE == 0 )); then
|
if (( $VERBOSE == 0 )); then
|
||||||
|
|
|
@ -77,11 +77,23 @@ if [[ ! -f "$LOG_DIR/$LOG_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
if [[ -f "$PLANET_DIR/$LOCK_FILE" ]]; then
|
||||||
echo "there's a sync process running behind, please try again later.."
|
cur_date=`date +%Y%m%d%H%M`
|
||||||
exit 1
|
file_date=`cat "$PLANET_DIR/$LOCK_FILE"`
|
||||||
else
|
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"
|
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"
|
cd "$PLANET_DIR"
|
||||||
|
|
||||||
if (( $VERBOSE == 0 )); then
|
if (( $VERBOSE == 0 )); then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user