clean-cronjob.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  15. *
  16. * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
  17. */
  18. /**
  19. * Use this example to create a cronjob to clean up the paste entries which are over livetime.
  20. * Usually the cleanup is done at creation and works well. But if you have a high load
  21. * or very low load, those lifetime limits will not be checked correctly
  22. *
  23. * rename this file into a php file and create a cronjob which executes this file as
  24. * php cli command
  25. *
  26. * example runs every sunday : 0 0 * * 0 php /path/to/this/file.php
  27. *
  28. * you need to change PATH_TO_MANCUBUS_CLASS to find the required PHP class
  29. */
  30. # Encoding and error reporting setting
  31. mb_http_output('UTF-8');
  32. mb_internal_encoding('UTF-8');
  33. error_reporting(-1); // E_ALL & E_STRICT
  34. # default time setting
  35. date_default_timezone_set('Europe/Berlin');
  36. # PATH to mancubus.class.php
  37. define('PATH_TO_MANCUBUS_CLASS','/path/to/selfpaste/mancubus.class.php');
  38. # verbose output
  39. # false no output
  40. # true for output
  41. $verbose=false;
  42. require_once(PATH_TO_MANCUBUS_CLASS);
  43. if($verbose == true) echo "Selfpaste cleanup start\n";
  44. $mancubus = new Mancubus();
  45. $mancubus->cleanupCronjob($verbose);
  46. if($verbose == true) echo "Selfpaste cleanup end\n";