Advertisement
goebelmasse

Cleanup Gwibber's database to reduce CPU consumption

Apr 26th, 2013
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. #!/bin/bash
  2. # $Id: cleanup-gwibber,v 1.1 2013/04/26 15:00:20 elias Exp $
  3. # Remove obsolete junk from gwibber's sqlite database
  4. #
  5. # Sorry, I do my calculations in bash syntax.
  6. #
  7. ########################################################################
  8. #
  9. # Configuration
  10. # -------------
  11. #
  12. # Directory for Gwibber's database
  13. #
  14. db_dir=~/.config/gwibber
  15. #
  16. # Name of Gwibber's database
  17. #
  18. db_name=gwibber.sqlite
  19. #
  20. # Number of days messages should be kept in the database
  21. #
  22. db_keepdays=30
  23. #
  24. ########################################################################
  25. #
  26. # Program
  27. # -------
  28. #
  29. db_path=$db_dir/$db_name
  30. db_keepsecs=$(($db_keepdays * 24 * 60 * 60))
  31. db_deletebefore=$((`date +%s` - $db_keepsecs))
  32. #
  33. sqlite3 "$db_path" <<EOF
  34. delete from messages where time < $db_deletebefore;
  35. vacuum;
  36. EOF
  37. #
  38. ########################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement