From 8767d434c61f6973dd00a31a2c97d0e636092b33 Mon Sep 17 00:00:00 2001 From: amplifi Date: Fri, 30 Sep 2016 23:02:43 +1000 Subject: [PATCH] Add cron job to prune MEDIA_ROOT files Runs daily at 12:05AM to remove media files more than 1 day old --- provision/roles/webserver/production/tasks/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/provision/roles/webserver/production/tasks/main.yml b/provision/roles/webserver/production/tasks/main.yml index 60799aa83..631b3336c 100644 --- a/provision/roles/webserver/production/tasks/main.yml +++ b/provision/roles/webserver/production/tasks/main.yml @@ -67,6 +67,13 @@ src="{{ application_path }}app/dist" state=link +- name: Create cron job to prune MEDIA_ROOT files + become: yes + become_user: root + cron: name="prune django media files" minute=5 hour=0 + user="root" + job="find {{ application_path }}cadasta/media/s3/* -type f -ctime +1 -exec rm {} \\; > /var/log/django/prune_media.log" + - name: Copy uwsgi_params to base directory become: yes become_user: "{{ app_user }}"