WordPress makes it super simple to run cronjobs.. To add one, just place the following code in your functions.php file and change the function/action prefix’s to your relevant plugin name/functions.
A little break down for those unfamiliar: the first action runs mypluginschedulecron() on each load. If your cronjob (myplugincronjob) is not registered, it‘s scheduled into WordPress’s cron and becomes a hook. Once it’s registered/schedualed with WordPress, the second action myplugincronjob is usable and runs your cronjob function (myplugincronfunction).
If you want your cronjob to occur less frequent than ‘daily‘, you need to add a additional timespan. Since what I’m writting this for has dynamic timespans, I’ve added several intervals for weekly, monthly, quaterly, biyearly, and yearly cronjobs:
If you’re uncertain if your cron function is working and want to test it, you can uncomment the third action and refresh the page (to run what WordPress cronjob will run on it’s intervals). If you’re uncertain if your cronjob is actually scheduled you can install Cron View, a plugin that displays the available schedules and the scheduled tasks.
This isn’t related to this website, this is just a PSA:
I bought a PC coffee maker, it was more expensive then it should of been, but it looked good in my new kitchen and I knew it would pay for itself eventually.
Worked fine, did the job for months – then about 8 months in, after the brew cycle (4-5minutes) the most annoying, loud beeping would occur. It was as if the danm machine was whining for attention.
Turns out it was, in the manual that I obviously threw out because who keeps stuff like that, it mentions a cleaning reminder setting, that beeps until you hold down the “Auto” button for three seconds to acknowledge “yes I’ve cleaned you”. From the Manual
Your coffee maker is equipped with a cleaning reminder alarm. When your coffee maker has been used 200 times, it will beep to remind you to clean it. To turn off the beeping simply press the AUTO button for 3 seconds. The sound will stop and the coffee makers internal counter will reset to zero,
Kudos to the makers for installing a feature to prevent people from getting sick or keep the coffee at it’s best – but shame on you for not writting it on the machine itself and expecting everyone to keep the box+manual.