Expire build artifacts

Can we get some cleanup shell scripts for e.g. following tasks:

  • delete CI artifacts older than X days
  • delete builds (from db) older than X days.

is there already a solution, for the (db task i found a few samples) but not for the disk-cleanup.