{"id":1204,"date":"2022-06-11T02:59:17","date_gmt":"2022-06-10T18:59:17","guid":{"rendered":"https:\/\/www.cith.ml:5444\/?p=1204"},"modified":"2023-09-08T17:17:55","modified_gmt":"2023-09-08T09:17:55","slug":"nextcloud-cron-php-%e6%af%8f5%e5%88%86%e9%92%9f%e8%bf%90%e8%a1%8c%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/blog.cithwu.com\/wp5444\/nextcloud-cron-php-%e6%af%8f5%e5%88%86%e9%92%9f%e8%bf%90%e8%a1%8c%e8%ae%be%e7%bd%ae\/","title":{"rendered":"Nextcloud cron.php \u6bcf5\u5206\u949f\u8fd0\u884c\u8bbe\u7f6e"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">systemd<a href=\"https:\/\/docs.nextcloud.com\/server\/24\/admin_manual\/configuration_server\/background_jobs_configuration.html#systemd\">\uf0c1<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If systemd is installed on the system, a systemd timer could be an alternative to a cronjob.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This approach requires two files: <strong>nextcloudcron.service<\/strong> and <strong>nextcloudcron.timer<\/strong>. Create these two files in <code>\/etc\/systemd\/system\/<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>nextcloudcron.service<\/strong> should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Unit]\nDescription=Nextcloud cron.php job\n\n[Service]\nUser=apache\nExecStart=\/usr\/bin\/php -f \/var\/www\/html\/nextcloud\/cron.php\nKillMode=process\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace the user <code>www-data<\/code> with the user of your http server and <code>\/var\/www\/nextcloud\/cron.php<\/code> with the location of <strong>cron.php<\/strong> in your nextcloud directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>KillMode=process<\/code> setting is necessary for external programs that are started by the cron job to keep running after the cron job has finished.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the <strong>.service<\/strong> unit file does not need an <code>[Install]<\/code> section. Please check your setup because we recommended it in earlier versions of this admin manual.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>nextcloudcron.timer<\/strong> should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[Unit]\nDescription=Run Nextcloud cron.php every 5 minutes\n\n[Timer]\nOnBootSec=5min\nOnUnitActiveSec=5min\nUnit=nextcloudcron.service\n\n[Install]\nWantedBy=timers.target\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The important parts in the timer-unit are <code>OnBootSec<\/code> and <code>OnUnitActiveSec<\/code>. <code>OnBootSec<\/code> will start the timer 5 minutes after boot, otherwise you would have to start it manually after every boot. <code>OnUnitActiveSec<\/code> will set a 5 minute timer after the service-unit was last activated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now all that is left is to start and enable the timer by running this command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable --now nextcloudcron.timer\n\nphp.ini  \u52a0\u5165  apc.enable_cli=1\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>systemd\uf0c1 If syst&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,9],"tags":[],"class_list":["post-1204","post","type-post","status-publish","format-standard","hentry","category-linux","category-9"],"_links":{"self":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/comments?post=1204"}],"version-history":[{"count":4,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1204\/revisions"}],"predecessor-version":[{"id":1312,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1204\/revisions\/1312"}],"wp:attachment":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/media?parent=1204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/categories?post=1204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/tags?post=1204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}