@@ -41,65 +41,65 @@ |
||
| 41 | 41 | define('OC_CONSOLE', 1); |
| 42 | 42 | |
| 43 | 43 | function exceptionHandler($exception) { |
| 44 | - echo "An unhandled exception has been thrown:" . PHP_EOL; |
|
| 45 | - echo $exception; |
|
| 46 | - exit(1); |
|
| 44 | + echo "An unhandled exception has been thrown:" . PHP_EOL; |
|
| 45 | + echo $exception; |
|
| 46 | + exit(1); |
|
| 47 | 47 | } |
| 48 | 48 | try { |
| 49 | - require_once __DIR__ . '/lib/base.php'; |
|
| 49 | + require_once __DIR__ . '/lib/base.php'; |
|
| 50 | 50 | |
| 51 | - // set to run indefinitely if needed |
|
| 52 | - if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 53 | - @set_time_limit(0); |
|
| 54 | - } |
|
| 51 | + // set to run indefinitely if needed |
|
| 52 | + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 53 | + @set_time_limit(0); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if (!OC::$CLI) { |
|
| 57 | - echo "This script can be run from the command line only" . PHP_EOL; |
|
| 58 | - exit(1); |
|
| 59 | - } |
|
| 56 | + if (!OC::$CLI) { |
|
| 57 | + echo "This script can be run from the command line only" . PHP_EOL; |
|
| 58 | + exit(1); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - set_exception_handler('exceptionHandler'); |
|
| 61 | + set_exception_handler('exceptionHandler'); |
|
| 62 | 62 | |
| 63 | - if (!function_exists('posix_getuid')) { |
|
| 64 | - echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 65 | - exit(1); |
|
| 66 | - } |
|
| 67 | - $user = posix_getuid(); |
|
| 68 | - $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 69 | - if ($user !== $configUser) { |
|
| 70 | - echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 71 | - echo "Current user id: " . $user . PHP_EOL; |
|
| 72 | - echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 73 | - echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL; |
|
| 74 | - echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL; |
|
| 75 | - exit(1); |
|
| 76 | - } |
|
| 63 | + if (!function_exists('posix_getuid')) { |
|
| 64 | + echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 65 | + exit(1); |
|
| 66 | + } |
|
| 67 | + $user = posix_getuid(); |
|
| 68 | + $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 69 | + if ($user !== $configUser) { |
|
| 70 | + echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 71 | + echo "Current user id: " . $user . PHP_EOL; |
|
| 72 | + echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 73 | + echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL; |
|
| 74 | + echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL; |
|
| 75 | + exit(1); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $oldWorkingDir = getcwd(); |
|
| 79 | - if ($oldWorkingDir === false) { |
|
| 80 | - echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 81 | - echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL; |
|
| 82 | - } elseif ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) { |
|
| 83 | - echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 84 | - echo "Can't change to Nextcloud root directory." . PHP_EOL; |
|
| 85 | - exit(1); |
|
| 86 | - } |
|
| 78 | + $oldWorkingDir = getcwd(); |
|
| 79 | + if ($oldWorkingDir === false) { |
|
| 80 | + echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 81 | + echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL; |
|
| 82 | + } elseif ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) { |
|
| 83 | + echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 84 | + echo "Can't change to Nextcloud root directory." . PHP_EOL; |
|
| 85 | + exit(1); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - if (!function_exists('pcntl_signal') && !in_array('--no-warnings', $argv)) { |
|
| 89 | - echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php" . PHP_EOL; |
|
| 90 | - } |
|
| 88 | + if (!function_exists('pcntl_signal') && !in_array('--no-warnings', $argv)) { |
|
| 89 | + echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php" . PHP_EOL; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $application = new Application( |
|
| 93 | - \OC::$server->getConfig(), |
|
| 94 | - \OC::$server->getEventDispatcher(), |
|
| 95 | - \OC::$server->getRequest(), |
|
| 96 | - \OC::$server->getLogger(), |
|
| 97 | - \OC::$server->query(\OC\MemoryInfo::class) |
|
| 98 | - ); |
|
| 99 | - $application->loadCommands(new ArgvInput(), new ConsoleOutput()); |
|
| 100 | - $application->run(); |
|
| 92 | + $application = new Application( |
|
| 93 | + \OC::$server->getConfig(), |
|
| 94 | + \OC::$server->getEventDispatcher(), |
|
| 95 | + \OC::$server->getRequest(), |
|
| 96 | + \OC::$server->getLogger(), |
|
| 97 | + \OC::$server->query(\OC\MemoryInfo::class) |
|
| 98 | + ); |
|
| 99 | + $application->loadCommands(new ArgvInput(), new ConsoleOutput()); |
|
| 100 | + $application->run(); |
|
| 101 | 101 | } catch (Exception $ex) { |
| 102 | - exceptionHandler($ex); |
|
| 102 | + exceptionHandler($ex); |
|
| 103 | 103 | } catch (Error $ex) { |
| 104 | - exceptionHandler($ex); |
|
| 104 | + exceptionHandler($ex); |
|
| 105 | 105 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | */ |
| 34 | 34 | |
| 35 | -require_once __DIR__ . '/lib/versioncheck.php'; |
|
| 35 | +require_once __DIR__.'/lib/versioncheck.php'; |
|
| 36 | 36 | |
| 37 | 37 | use OC\Console\Application; |
| 38 | 38 | use Symfony\Component\Console\Input\ArgvInput; |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | define('OC_CONSOLE', 1); |
| 42 | 42 | |
| 43 | 43 | function exceptionHandler($exception) { |
| 44 | - echo "An unhandled exception has been thrown:" . PHP_EOL; |
|
| 44 | + echo "An unhandled exception has been thrown:".PHP_EOL; |
|
| 45 | 45 | echo $exception; |
| 46 | 46 | exit(1); |
| 47 | 47 | } |
| 48 | 48 | try { |
| 49 | - require_once __DIR__ . '/lib/base.php'; |
|
| 49 | + require_once __DIR__.'/lib/base.php'; |
|
| 50 | 50 | |
| 51 | 51 | // set to run indefinitely if needed |
| 52 | 52 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
@@ -54,39 +54,39 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if (!OC::$CLI) { |
| 57 | - echo "This script can be run from the command line only" . PHP_EOL; |
|
| 57 | + echo "This script can be run from the command line only".PHP_EOL; |
|
| 58 | 58 | exit(1); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | set_exception_handler('exceptionHandler'); |
| 62 | 62 | |
| 63 | 63 | if (!function_exists('posix_getuid')) { |
| 64 | - echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 64 | + echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php".PHP_EOL; |
|
| 65 | 65 | exit(1); |
| 66 | 66 | } |
| 67 | 67 | $user = posix_getuid(); |
| 68 | - $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 68 | + $configUser = fileowner(OC::$configDir.'config.php'); |
|
| 69 | 69 | if ($user !== $configUser) { |
| 70 | - echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 71 | - echo "Current user id: " . $user . PHP_EOL; |
|
| 72 | - echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 73 | - echo "Try adding 'sudo -u #" . $configUser . "' to the beginning of the command (without the single quotes)" . PHP_EOL; |
|
| 74 | - echo "If running with 'docker exec' try adding the option '-u " . $configUser . "' to the docker command (without the single quotes)" . PHP_EOL; |
|
| 70 | + echo "Console has to be executed with the user that owns the file config/config.php".PHP_EOL; |
|
| 71 | + echo "Current user id: ".$user.PHP_EOL; |
|
| 72 | + echo "Owner id of config.php: ".$configUser.PHP_EOL; |
|
| 73 | + echo "Try adding 'sudo -u #".$configUser."' to the beginning of the command (without the single quotes)".PHP_EOL; |
|
| 74 | + echo "If running with 'docker exec' try adding the option '-u ".$configUser."' to the docker command (without the single quotes)".PHP_EOL; |
|
| 75 | 75 | exit(1); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $oldWorkingDir = getcwd(); |
| 79 | 79 | if ($oldWorkingDir === false) { |
| 80 | - echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 81 | - echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL; |
|
| 80 | + echo "This script can be run from the Nextcloud root directory only.".PHP_EOL; |
|
| 81 | + echo "Can't determine current working dir - the script will continue to work but be aware of the above fact.".PHP_EOL; |
|
| 82 | 82 | } elseif ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) { |
| 83 | - echo "This script can be run from the Nextcloud root directory only." . PHP_EOL; |
|
| 84 | - echo "Can't change to Nextcloud root directory." . PHP_EOL; |
|
| 83 | + echo "This script can be run from the Nextcloud root directory only.".PHP_EOL; |
|
| 84 | + echo "Can't change to Nextcloud root directory.".PHP_EOL; |
|
| 85 | 85 | exit(1); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if (!function_exists('pcntl_signal') && !in_array('--no-warnings', $argv)) { |
| 89 | - echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php" . PHP_EOL; |
|
| 89 | + echo "The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php".PHP_EOL; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $application = new Application( |
@@ -39,125 +39,125 @@ |
||
| 39 | 39 | require_once __DIR__ . '/lib/versioncheck.php'; |
| 40 | 40 | |
| 41 | 41 | try { |
| 42 | - require_once __DIR__ . '/lib/base.php'; |
|
| 43 | - |
|
| 44 | - if (\OCP\Util::needUpgrade()) { |
|
| 45 | - \OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']); |
|
| 46 | - exit; |
|
| 47 | - } |
|
| 48 | - if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
| 49 | - \OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']); |
|
| 50 | - exit; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // load all apps to get all api routes properly setup |
|
| 54 | - OC_App::loadApps(); |
|
| 55 | - |
|
| 56 | - \OC::$server->getSession()->close(); |
|
| 57 | - |
|
| 58 | - // initialize a dummy memory session |
|
| 59 | - $session = new \OC\Session\Memory(''); |
|
| 60 | - $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
| 61 | - $session = $cryptoWrapper->wrapSession($session); |
|
| 62 | - \OC::$server->setSession($session); |
|
| 63 | - |
|
| 64 | - $logger = \OC::$server->getLogger(); |
|
| 65 | - $config = \OC::$server->getConfig(); |
|
| 66 | - |
|
| 67 | - // Don't do anything if Nextcloud has not been installed |
|
| 68 | - if (!$config->getSystemValue('installed', false)) { |
|
| 69 | - exit(0); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - \OC::$server->getTempManager()->cleanOld(); |
|
| 73 | - |
|
| 74 | - // Exit if background jobs are disabled! |
|
| 75 | - $appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax'); |
|
| 76 | - if ($appMode === 'none') { |
|
| 77 | - if (OC::$CLI) { |
|
| 78 | - echo 'Background Jobs are disabled!' . PHP_EOL; |
|
| 79 | - } else { |
|
| 80 | - OC_JSON::error(['data' => ['message' => 'Background jobs disabled!']]); |
|
| 81 | - } |
|
| 82 | - exit(1); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if (OC::$CLI) { |
|
| 86 | - // set to run indefinitely if needed |
|
| 87 | - if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 88 | - @set_time_limit(0); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // the cron job must be executed with the right user |
|
| 92 | - if (!function_exists('posix_getuid')) { |
|
| 93 | - echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 94 | - exit(1); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $user = posix_getuid(); |
|
| 98 | - $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 99 | - if ($user !== $configUser) { |
|
| 100 | - echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 101 | - echo "Current user id: " . $user . PHP_EOL; |
|
| 102 | - echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 103 | - exit(1); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - // We call Nextcloud from the CLI (aka cron) |
|
| 108 | - if ($appMode !== 'cron') { |
|
| 109 | - $config->setAppValue('core', 'backgroundjobs_mode', 'cron'); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // Work |
|
| 113 | - $jobList = \OC::$server->getJobList(); |
|
| 114 | - |
|
| 115 | - // We only ask for jobs for 14 minutes, because after 5 minutes the next |
|
| 116 | - // system cron task should spawn and we want to have at most three |
|
| 117 | - // cron jobs running in parallel. |
|
| 118 | - $endTime = time() + 14 * 60; |
|
| 119 | - |
|
| 120 | - $executedJobs = []; |
|
| 121 | - while ($job = $jobList->getNext()) { |
|
| 122 | - if (isset($executedJobs[$job->getId()])) { |
|
| 123 | - $jobList->unlockJob($job); |
|
| 124 | - break; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $job->execute($jobList, $logger); |
|
| 128 | - // clean up after unclean jobs |
|
| 129 | - \OC_Util::tearDownFS(); |
|
| 130 | - |
|
| 131 | - $jobList->setLastJob($job); |
|
| 132 | - $executedJobs[$job->getId()] = true; |
|
| 133 | - unset($job); |
|
| 134 | - |
|
| 135 | - if (time() > $endTime) { |
|
| 136 | - break; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - // We call cron.php from some website |
|
| 141 | - if ($appMode === 'cron') { |
|
| 142 | - // Cron is cron :-P |
|
| 143 | - OC_JSON::error(['data' => ['message' => 'Backgroundjobs are using system cron!']]); |
|
| 144 | - } else { |
|
| 145 | - // Work and success :-) |
|
| 146 | - $jobList = \OC::$server->getJobList(); |
|
| 147 | - $job = $jobList->getNext(); |
|
| 148 | - if ($job != null) { |
|
| 149 | - $job->execute($jobList, $logger); |
|
| 150 | - $jobList->setLastJob($job); |
|
| 151 | - } |
|
| 152 | - OC_JSON::success(); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - // Log the successful cron execution |
|
| 157 | - $config->setAppValue('core', 'lastcron', time()); |
|
| 158 | - exit(); |
|
| 42 | + require_once __DIR__ . '/lib/base.php'; |
|
| 43 | + |
|
| 44 | + if (\OCP\Util::needUpgrade()) { |
|
| 45 | + \OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']); |
|
| 46 | + exit; |
|
| 47 | + } |
|
| 48 | + if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) { |
|
| 49 | + \OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']); |
|
| 50 | + exit; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // load all apps to get all api routes properly setup |
|
| 54 | + OC_App::loadApps(); |
|
| 55 | + |
|
| 56 | + \OC::$server->getSession()->close(); |
|
| 57 | + |
|
| 58 | + // initialize a dummy memory session |
|
| 59 | + $session = new \OC\Session\Memory(''); |
|
| 60 | + $cryptoWrapper = \OC::$server->getSessionCryptoWrapper(); |
|
| 61 | + $session = $cryptoWrapper->wrapSession($session); |
|
| 62 | + \OC::$server->setSession($session); |
|
| 63 | + |
|
| 64 | + $logger = \OC::$server->getLogger(); |
|
| 65 | + $config = \OC::$server->getConfig(); |
|
| 66 | + |
|
| 67 | + // Don't do anything if Nextcloud has not been installed |
|
| 68 | + if (!$config->getSystemValue('installed', false)) { |
|
| 69 | + exit(0); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + \OC::$server->getTempManager()->cleanOld(); |
|
| 73 | + |
|
| 74 | + // Exit if background jobs are disabled! |
|
| 75 | + $appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax'); |
|
| 76 | + if ($appMode === 'none') { |
|
| 77 | + if (OC::$CLI) { |
|
| 78 | + echo 'Background Jobs are disabled!' . PHP_EOL; |
|
| 79 | + } else { |
|
| 80 | + OC_JSON::error(['data' => ['message' => 'Background jobs disabled!']]); |
|
| 81 | + } |
|
| 82 | + exit(1); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if (OC::$CLI) { |
|
| 86 | + // set to run indefinitely if needed |
|
| 87 | + if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
| 88 | + @set_time_limit(0); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // the cron job must be executed with the right user |
|
| 92 | + if (!function_exists('posix_getuid')) { |
|
| 93 | + echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 94 | + exit(1); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $user = posix_getuid(); |
|
| 98 | + $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 99 | + if ($user !== $configUser) { |
|
| 100 | + echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 101 | + echo "Current user id: " . $user . PHP_EOL; |
|
| 102 | + echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 103 | + exit(1); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + // We call Nextcloud from the CLI (aka cron) |
|
| 108 | + if ($appMode !== 'cron') { |
|
| 109 | + $config->setAppValue('core', 'backgroundjobs_mode', 'cron'); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // Work |
|
| 113 | + $jobList = \OC::$server->getJobList(); |
|
| 114 | + |
|
| 115 | + // We only ask for jobs for 14 minutes, because after 5 minutes the next |
|
| 116 | + // system cron task should spawn and we want to have at most three |
|
| 117 | + // cron jobs running in parallel. |
|
| 118 | + $endTime = time() + 14 * 60; |
|
| 119 | + |
|
| 120 | + $executedJobs = []; |
|
| 121 | + while ($job = $jobList->getNext()) { |
|
| 122 | + if (isset($executedJobs[$job->getId()])) { |
|
| 123 | + $jobList->unlockJob($job); |
|
| 124 | + break; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $job->execute($jobList, $logger); |
|
| 128 | + // clean up after unclean jobs |
|
| 129 | + \OC_Util::tearDownFS(); |
|
| 130 | + |
|
| 131 | + $jobList->setLastJob($job); |
|
| 132 | + $executedJobs[$job->getId()] = true; |
|
| 133 | + unset($job); |
|
| 134 | + |
|
| 135 | + if (time() > $endTime) { |
|
| 136 | + break; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + // We call cron.php from some website |
|
| 141 | + if ($appMode === 'cron') { |
|
| 142 | + // Cron is cron :-P |
|
| 143 | + OC_JSON::error(['data' => ['message' => 'Backgroundjobs are using system cron!']]); |
|
| 144 | + } else { |
|
| 145 | + // Work and success :-) |
|
| 146 | + $jobList = \OC::$server->getJobList(); |
|
| 147 | + $job = $jobList->getNext(); |
|
| 148 | + if ($job != null) { |
|
| 149 | + $job->execute($jobList, $logger); |
|
| 150 | + $jobList->setLastJob($job); |
|
| 151 | + } |
|
| 152 | + OC_JSON::success(); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + // Log the successful cron execution |
|
| 157 | + $config->setAppValue('core', 'lastcron', time()); |
|
| 158 | + exit(); |
|
| 159 | 159 | } catch (Exception $ex) { |
| 160 | - \OC::$server->getLogger()->logException($ex, ['app' => 'cron']); |
|
| 160 | + \OC::$server->getLogger()->logException($ex, ['app' => 'cron']); |
|
| 161 | 161 | } catch (Error $ex) { |
| 162 | - \OC::$server->getLogger()->logException($ex, ['app' => 'cron']); |
|
| 162 | + \OC::$server->getLogger()->logException($ex, ['app' => 'cron']); |
|
| 163 | 163 | } |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | -require_once __DIR__ . '/lib/versioncheck.php'; |
|
| 39 | +require_once __DIR__.'/lib/versioncheck.php'; |
|
| 40 | 40 | |
| 41 | 41 | try { |
| 42 | - require_once __DIR__ . '/lib/base.php'; |
|
| 42 | + require_once __DIR__.'/lib/base.php'; |
|
| 43 | 43 | |
| 44 | 44 | if (\OCP\Util::needUpgrade()) { |
| 45 | 45 | \OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax'); |
| 76 | 76 | if ($appMode === 'none') { |
| 77 | 77 | if (OC::$CLI) { |
| 78 | - echo 'Background Jobs are disabled!' . PHP_EOL; |
|
| 78 | + echo 'Background Jobs are disabled!'.PHP_EOL; |
|
| 79 | 79 | } else { |
| 80 | 80 | OC_JSON::error(['data' => ['message' => 'Background jobs disabled!']]); |
| 81 | 81 | } |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | // the cron job must be executed with the right user |
| 92 | 92 | if (!function_exists('posix_getuid')) { |
| 93 | - echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; |
|
| 93 | + echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php".PHP_EOL; |
|
| 94 | 94 | exit(1); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $user = posix_getuid(); |
| 98 | - $configUser = fileowner(OC::$configDir . 'config.php'); |
|
| 98 | + $configUser = fileowner(OC::$configDir.'config.php'); |
|
| 99 | 99 | if ($user !== $configUser) { |
| 100 | - echo "Console has to be executed with the user that owns the file config/config.php" . PHP_EOL; |
|
| 101 | - echo "Current user id: " . $user . PHP_EOL; |
|
| 102 | - echo "Owner id of config.php: " . $configUser . PHP_EOL; |
|
| 100 | + echo "Console has to be executed with the user that owns the file config/config.php".PHP_EOL; |
|
| 101 | + echo "Current user id: ".$user.PHP_EOL; |
|
| 102 | + echo "Owner id of config.php: ".$configUser.PHP_EOL; |
|
| 103 | 103 | exit(1); |
| 104 | 104 | } |
| 105 | 105 | |