diff --git a/INSTALL.md b/INSTALL.md index 0ee56255..71cf2937 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -430,7 +430,13 @@ Once a week or so it's good to run `remove_orphan_files.sh` to save disk space: 5 4 * * 1 rimu cd /home/rimu/pyfedi && /home/rimu/pyfedi/remove_orphan_files.sh ``` -If celery is hanging occasionally (we're looking into it but it's a hard one to solve), put this script in /etc/cron.hourly: +One per day there are some maintenance tasks that PieFed needs to do: + +``` +5 2 * * * rimu cd /home/rimu/pyfedi && /home/rimu/pyfedi/daily.sh +``` + +If celery is hanging occasionally, put this script in /etc/cron.hourly: ``` #!/bin/bash diff --git a/app/cli.py b/app/cli.py index f1c6b69c..ddedb795 100644 --- a/app/cli.py +++ b/app/cli.py @@ -181,10 +181,6 @@ def register(app): post_delete_post(community, post, post.user_id, federate_all_communities=False) community.post_count -= 1 - # Remove activity older than 3 days - db.session.query(ActivityPubLog).filter(ActivityPubLog.created_at < utcnow() - timedelta(days=3)).delete() - db.session.commit() - # Ensure accurate count of posts associated with each hashtag for tag in Tag.query.all(): post_count = db.session.execute(text('SELECT COUNT(post_id) as c FROM "post_tag" WHERE tag_id = :tag_id'), diff --git a/daily.sh b/daily.sh new file mode 100755 index 00000000..7f75d97e --- /dev/null +++ b/daily.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source venv/bin/activate +export FLASK_APP=pyfedi.py +flask daily-maintenance