diff --git a/cronjobs/archive_cleanup.php b/cronjobs/archive_cleanup.php deleted file mode 100755 index 350d7c3d..00000000 --- a/cronjobs/archive_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -purgeArchive(); -if ($affected_rows === false) { - $log->logError("Failed to delete archived shares, not critical but should be checked: " . $share->getCronError()); - $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); -} else { - $log->logDebug("Deleted $affected_rows archived shares this run"); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/notification_cleanup.php b/cronjobs/notification_cleanup.php deleted file mode 100755 index 566b226f..00000000 --- a/cronjobs/notification_cleanup.php +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/php -cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { - $notification->deleted == 0 ? $log->logDebug('Did not delete any old notifications') : $log->logInfo('Deleted ' . $notification->deleted . ' notifications'); -} else { - $log->logError('Failed to delete notifications: ' . $notification->getCronError()); - $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/run-crons.sh b/cronjobs/run-crons.sh index 66c59c1f..d1cca24b 100755 --- a/cronjobs/run-crons.sh +++ b/cronjobs/run-crons.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/run-maintenance.sh b/cronjobs/run-maintenance.sh index 1161f4cd..54799323 100755 --- a/cronjobs/run-maintenance.sh +++ b/cronjobs/run-maintenance.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="tickerupdate.php notifications.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/tables_cleanup.php b/cronjobs/tables_cleanup.php new file mode 100755 index 00000000..04386133 --- /dev/null +++ b/cronjobs/tables_cleanup.php @@ -0,0 +1,79 @@ +#!/usr/bin/php +logInfo(sprintf($strLogMask, 'Process', 'Affected', 'Runtime', 'Status', 'Message')); + +// Cleanup old notifications +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($notification->cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { + $affected = $notification->deleted; + $affected == 0 ? $message = 'No notifications deleted' : $message = 'Deleted notifications older than ' . $setting->getValue('notifications_cleanup_time', 7) . ' days'; +} else { + $message = 'Failed to delete notifications: ' . $notification->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupNotifications', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Cleanup old expired tokens +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($oToken->cleanupTokens()) { + $affected = $oToken->deleted; + $affected == 0 ? $message = 'No tokens deleted' : $message = 'Deleted expired tokens'; +} else { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupTokens', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Clenaup shares archive +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = $share->purgeArchive(); +if ($affected === false) { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); +} else { + $affected == 0 ? $message = 'No shares deleted' : $message = 'Deleted old shares'; +} +$log->logInfo(sprintf($strLogMask, 'purgeArchive', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + + +// Cron cleanup and monitoring +require_once('cron_end.inc.php'); +?> diff --git a/cronjobs/token_cleanup.php b/cronjobs/token_cleanup.php deleted file mode 100755 index dec00bd9..00000000 --- a/cronjobs/token_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -cleanupTokens()) { - $oToken->deleted == 0 ? $log->logDebug('Did not find any expired tokens') : $log->logInfo('Deleted ' . $oToken->deleted . ' expired tokens'); -} else { - $log->logError('Failed to delete expired tokens: ' . $oToken->getCronError()); - // Treat as critical since tokens like password resets will never expire - $monitoring->endCronjob($cron_name, 'E0074', 1, true, true); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/public/include/config/monitor_crons.inc.php b/public/include/config/monitor_crons.inc.php index 5b69d6f1..98b8eb0f 100644 --- a/public/include/config/monitor_crons.inc.php +++ b/public/include/config/monitor_crons.inc.php @@ -2,7 +2,7 @@ // Small helper array that may be used on some page controllers to // fetch the crons we wish to monitor -$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','notification_cleanup','blockupdate','findblock','notifications','tickerupdate'); +$aMonitorCrons = array('statistics','payouts','tables_cleanup','blockupdate','findblock','notifications','tickerupdate'); switch ($config['payout_system']) { case 'pplns':