expire old posts?

edited May 2012 in General
In friendica, I can set my posts to expire after a given number of days.
This destroys the evidence, keeps the db from expanding infinitely, or serves other purposes.
So, I was thinking of how to make statusnet do the same thing.

I think I have a script that will delete posts 3 months old or older, and I believe I can have cron fire it off with whatever desired frequency (weekly, monthly, whatever).

#!/bin/bash
# script to expire status.net posts older than 3 months old
# by tony baldwin | www.tonybaldwin.me
# released according to GPL v. 3

datenow=$(date +%Y%m%d)
datemin3=$(date -d "$datenow - 3 months" "+%Y%m%d")

query="DELETE FROM `notice` WHERE `created` <= '$datemin3 01:01:01'"

# edit the $PASSWORD to reflect your password
# and $DBNAME to reflect your db's name
/usr/bin/mysql -D $DBNAME -u root -password="$PASSWORD" << eof
$query
exit


Pretty simple, really, but I haven't tested it.
What do you think?

Comments

  • I've been thinking about this from a privacy standpoint. You have no idea today which posts you'll wish you'd protected/deleted five years from now. Thus, it is probably a good idea for all posts on every service to expire-by-default in 90-180 days. Of course, users might wish to save an occasional post (such as a bookmark), so there should be a way to mark a post as saved.

    Having said all of that, your script sounds like a good first step along that road.
  • I have it up on github here: https://github.com/tonybaldwin/statexpire
    It now also expires replies and conversations, in addition to notices.
  • Oh, and the code on github is tested and working on my own installation.
    I have cron fire it off a couple times/month.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID