Skip to content

Commit

Permalink
auto-delete archives of +1h
Browse files Browse the repository at this point in the history
  • Loading branch information
sdunesme committed Oct 24, 2022
1 parent 774ceb6 commit fea2276
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion archive_compression/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ COPY crontab /etc/cron.d/crontab

RUN apt-get update -y && apt-get install -y cron ffmpeg
RUN pip install numpy requests python-dotenv ffmpeg-python
RUN touch /var/log/archivecompression.log

RUN crontab /etc/cron.d/crontab

CMD ["crond", "-f"]
CMD cron && tail -f /var/log/archivecompression.log
2 changes: 1 addition & 1 deletion archive_compression/crontab
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0 2 * * * python /archive_compression.py >> /logfile
0 2 * * * python3 /archive_compression.py >> /var/log/archivecompression.log
10 changes: 9 additions & 1 deletion woodcamrm/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@ def records_check():

for clip in old_clips:
os.remove(clip)


# Remove archive clips older than 1hour
old_clips = [os.path.join(st.storage_path, 'archives', f) for f in os.listdir(os.path.join(st.storage_path, 'archives'))
if time.time() - os.stat(os.path.join(st.storage_path, 'archives', f)).st_mtime >= (60*60)
and not os.path.isdir(os.path.join(st.storage_path, 'archives', f))]

for clip in old_clips:
os.remove(clip)

# Update the jobs table in the database
jb.last_execution = datetime.now()
jb.state = 4
Expand Down

0 comments on commit fea2276

Please sign in to comment.