How to setup cron page handlers?

Hello Everyone,

I have setup some cron jobs that perform certain action based on the page handler. I can execute the same page handlers via browser, to ensure better security I changed the handler to have admin_gatekeeper so that only admins can execute these functionality. As soon as I add that, the cron stops working, am I supposed to do this a different way? What is the proper way to execute such cron handlers.

  • If the handlers are triggered by the cron daemon there's no user involved, so you can't check for an admin or any other user logged in. You could add some "secret code" to the url you use in the cronjob

    http://url.to.trigger.job?secret_code=12345

    and then check for existence and correctness of the code within your handler's callback

    $code_given = get_input('secret_code');

    if ($code_given == '12345') {

    ...