-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from jekhokie/add-prune-by-date
Add Prune Scripts for Date/Number Ranges
- Loading branch information
Showing
5 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# | ||
# Purpose: Prunes (removes) all captures older than $PRUNE_OLDER_THAN days old, including | ||
# database records and associated images/files on disk. | ||
|
||
# import common lib and settings | ||
. "$HOME/.noaa-v2.conf" | ||
. "$NOAA_HOME/scripts/common.sh" | ||
|
||
#Generate date since epoch in seconds - days | ||
let prunedate=$(date +%s)-$PRUNE_OLDER_THAN*24*60*60 | ||
|
||
log "Pruning captures..." "INFO" | ||
for img_path in $(sqlite3 ${DB_FILE} "select file_path from decoded_passes where pass_start < $prunedate;"); do | ||
find "${IMAGE_OUTPUT}/" -maxdepth 1 -type f -name "${img_path}*.jpg" exec rm -f {} \; | ||
find "${IMAGE_OUTPUT}/thumb/" -maxdepth 1 -type f -name "${img_path}*.jpg" exec rm -f {} \; | ||
log " ${img_path} file pruned" "INFO" | ||
sqlite3 "${DB_FILE}" "delete from decoded_passes where file_path = \"$img_path\";" | ||
log " Database entry pruned" "INFO" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters