From af25a2b739bc6611c1f220b7c7edb1f569362b80 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Tue, 12 Sep 2017 08:01:03 +0200 Subject: [PATCH] MDL-60094 administration: Add CLI script to kill all sessions --- admin/cli/kill_all_sessions.php | 55 +++++++++++++++++++++++++++++++++ admin/cli/purge_caches.php | 4 ++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 admin/cli/kill_all_sessions.php diff --git a/admin/cli/kill_all_sessions.php b/admin/cli/kill_all_sessions.php new file mode 100644 index 00000000000..9cf301d3cb5 --- /dev/null +++ b/admin/cli/kill_all_sessions.php @@ -0,0 +1,55 @@ +. + +/** + * CLI script to kill all user sessions without asking for confirmation. + * + * @package core + * @subpackage cli + * @copyright 2017 Alexander Bias + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +define('CLI_SCRIPT', true); + +require(__DIR__.'/../../config.php'); +require_once($CFG->libdir.'/clilib.php'); + +list($options, $unrecognized) = cli_get_params(array('help' => false), array('h' => 'help')); + +if ($unrecognized) { + $unrecognized = implode("\n ", $unrecognized); + cli_error(get_string('cliunknowoption', 'admin', $unrecognized), 2); +} + +if ($options['help']) { + $help = +"Kill all Moodle sessions + +Options: +-h, --help Print out this help + +Example: +\$sudo -u www-data /usr/bin/php admin/cli/kill_all_sessions.php +"; + + echo $help; + exit(0); +} + +\core\session\manager::kill_all_sessions(); + +exit(0); diff --git a/admin/cli/purge_caches.php b/admin/cli/purge_caches.php index 7c9d3447c04..64f29bd4247 100644 --- a/admin/cli/purge_caches.php +++ b/admin/cli/purge_caches.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * CLI script to purge caches without asking for confirmation. + * * @package core * @subpackage cli * @copyright 2011 David Mudrak @@ -50,4 +52,4 @@ Example: purge_all_caches(); -exit(0); \ No newline at end of file +exit(0); -- 2.43.0