clean-cronjob.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
  5. *
  6. * You should have received a copy of the
  7. * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
  8. * along with this program. If not, see http://www.sun.com/cddl/cddl.html
  9. *
  10. * 2019 - 2020 https://://www.bananas-playground.net/projekt/selfpaste
  11. */
  12. /**
  13. * Use this example to create a cronjob to clean up the paste entries which are over livetime.
  14. * Usually the cleanup is done at creation and works well. But if you have a high load
  15. * or very low load, those lifetime limits will not be checked correctly
  16. *
  17. * rename this file into a php file and create a cronjob which executes this file as
  18. * php cli command
  19. *
  20. * example runs very sunday : 0 0 * * 0 php /path/to/this/file.php
  21. *
  22. * you need to change PATH_TO_MANCUBUS_CLASS to find the required PHP class
  23. */
  24. # Encoding and error reporting setting
  25. mb_http_output('UTF-8');
  26. mb_internal_encoding('UTF-8');
  27. ini_set('error_reporting',-1); // E_ALL & E_STRICT
  28. # default time setting
  29. date_default_timezone_set('Europe/Berlin');
  30. # PATH to mancubus.class.php
  31. define('PATH_TO_MANCUBUS_CLASS','/path/to/selfpaste/mancubus.class.php');
  32. # verbose output
  33. # false no output
  34. # true for output
  35. $verbose=false;
  36. require_once(PATH_TO_MANCUBUS_CLASS);
  37. if($verbose == true) echo "Selfpaste cleanup start\n";
  38. $mancubus = new Mancubus();
  39. $mancubus->cleanupCronjob($verbose);
  40. if($verbose == true) echo "Selfpaste cleanup end\n";