Created
December 8, 2022 13:14
-
-
Save sneak/0e9cb0c96a31b40e0484e92669f4df6a to your computer and use it in GitHub Desktop.
mattermost message retention crontab
This file contains hidden or 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
#!/bin/bash | |
CID="$(docker ps | grep srv-captain--mm-postgres | awk '{print $1}')" | |
CMD=" | |
delete from posts where createat < extract(epoch from (now() - interval '1 months'))::int8 * 1000; | |
delete from reactions where postid not in (select id from posts); | |
delete from fileinfo where postid not in (select id from posts); | |
" | |
echo "$CMD" | docker exec -i $CID psql -U mattermost mattermost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment