Skip to content

Instantly share code, notes, and snippets.

@sneak
Created December 8, 2022 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sneak/0e9cb0c96a31b40e0484e92669f4df6a to your computer and use it in GitHub Desktop.
Save sneak/0e9cb0c96a31b40e0484e92669f4df6a to your computer and use it in GitHub Desktop.
mattermost message retention crontab
#!/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