Question

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?)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top