0

On cloudControl, I can either run a local task via a worker or I can run a cronjob.

What if I want to perform a local task on a regular basis (I don't want to call a publicly accessible website).

I see possible solutions:

  1. According to the documentation,

    "cronjobs on cloudControl are periodical calls to a URL you specify."

    So calling the file locally is not possible(?). So I'd have to create a page I can call via URL. And I have to perform checks, if the client is on localhost (=the server) -- I would like to avoid this way.

  2. I make the worker sleep() for the desired amount of time and then make it re-run.

    // do some arbitrary action
    Foo::doSomeAction();
    
    // e.g. sleep 1 day
    sleep(86400);
    
    // restart worker
    exit(2);
    

Which one is recommended?
(Or: Can I simply call a local file via cron?)

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116

1 Answers1

2

The first option is not possible, because the url request is made from a seperate webservice. You could either use HTTP authentication in the cron task, but the worker solution is also completely valid.

Just keep in mind that the worker can get migrated to a different server (in case of software updates or hardware failure), so do SomeAction() may get executed more often than once per day from time to time.

Stefan Friesel
  • 823
  • 5
  • 19
  • Adding to this, you can always use the cron Add-on to trigger an http request, and use that start a worker via the API. Regarding the worker restarts, if a worker is restarted due to a e.g. a node failure it keeps the same worker id. The worker id is available in the environment. You can use this to implement a locking mechanism, if it's important the task is never run more than once for example. – pst Oct 01 '13 at 08:08
  • Would you have any documentation or howtos available for these scenarios? – Gottlieb Notschnabel Oct 01 '13 at 10:05