{"id":5260,"date":"2025-12-05T01:46:54","date_gmt":"2025-12-05T01:46:54","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=5260"},"modified":"2025-12-05T01:46:54","modified_gmt":"2025-12-05T01:46:54","slug":"cron-occasional-tasks","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/cron-scheduled-tasks\/cron-examples\/cron-occasional-tasks","title":{"rendered":"Cron occasional tasks"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>  \/\/----- OCCASIONAL CRON TASKS -----\n  if (!$CronLastOccasionalRunTime = get_option('MYPLUGINNAME_CronOccasionalLastRunTime'))\n    $SecondsSinceOccasionalRunTime = 99999999;\n  else\n    $SecondsSinceOccasionalRunTime = strtotime(date(\"Y-m-d H:i:s\")) - strtotime($CronLastOccasionalRunTime);\n  if ($SecondsSinceOccasionalRunTime >= (5 * 60))     \/\/&lt;&lt;&lt;Set how often the occasional tasks should run\n  {\n    \/\/------------------------------------\n    \/\/----- DO OCCASIONAL CRON TASKS -----\n    \/\/------------------------------------\n  \n\n\n    \/\/>>>\n    if (function_exists('\\OdacAdminMessenger\\ApiSendMessageToAdmin'))\n      \\OdacAdminMessenger\\ApiSendMessageToAdmin(\"Ran occasional cron tasks\");\n    \/\/&lt;&lt;&lt;\n    \n    \/\/All done - Store the last run timestamp\n    update_option('MYPLUGINNAME_CronOccasionalLastRunTime', date(\"Y-m-d H:i:s\"), True);\n  }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[301],"tags":[],"class_list":["post-5260","post","type-post","status-publish","format-standard","hentry","category-cron-examples"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=5260"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5260\/revisions"}],"predecessor-version":[{"id":5261,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/5260\/revisions\/5261"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=5260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=5260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=5260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}