Fork me on GitHub

module for cron jobs  Bottom

  • is there a module out there to schedule / see whats scheduled for crons?

    if not i might write something this summer, the two thoughts ive had on it are either
    a) have the module ssl into the server you want to monitor cron jobs for and then it can get crons and set them via the admin interface. while that seems like a good idea it might be a potential security risk, maybe? thoughts?

    b) when installing the module install a script as a cron which checks (every 5 mins or something) the database zikula uses to see if the user has set a new job/update the jobs on the server and stuff, seems like it is probably safer but less function/harder setup


    anyone have thoughts?
  • There exist a module called scheduler by Mark West IIRC (http://community.zik…ub-tid-3-pid-68.htm). Not sure if it works on Zikula. Some other modules use an invisible block which display function triggers 'regularly executed' actions. Personally hate the latter solutions, though it might be the only solution if access to cron jobs is not available.

    Remember I did sort of scheduler for a client based on a crontab entry that invoked wget and did all kind of security checks.
  • the concept is interesting, in order to do that, perhaps you can create a "batch user" which will have specific permissions.

    But, how can we identified this user ,
    - ip ... no (the job will be run on the server)
    - user without login .. yes
    - user which can't use post or get value ...

    You've got 2 hours ^^
  • ip of server will be 127.0.0.1
    through wget you can use '--load-cookies=FILE' and thus be a logged in user

    I remember one specific issue with the cookie domain: it had to start with a dot '.domain.tld'.

    I used something like this in my crontab:

    Code

    55 22 * * * /usr/bin/wget --user-agent=scheduler@domain.tld http://www.domain.tld/scheduler.php > /dev/null


    and then this in scheduler.php:

    Code

    define('_SCHEDULERADMINEMAIL', 'xyz@domain.tld');
    define('_SCHEDULERAGENT', 'scheduler@domain.tld');
    define('_SCHEDULERUSER', 'auser');
    define('_SCHEDULERPASSWORD', 'apassword');

    define('_IMPORTSCHEDULERREPORTPATH', 'modules/amodule/logs/');

    scheduler_invoke();


    function scheduler_invoke()
    {
            if (!($_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR'] && $_SERVER['HTTP_USER_AGENT'] === _SCHEDULERAGENT)) {
                    echo ("Illegal invoke of portal scheduler!");
                    mail(_SCHEDULERADMINEMAIL, "Illegal invoke of portal scheduler!", "Hi Admin,\n\nOn ".date("Y-m-d h:i:s A")." it seems there was an illegal attempt to start the portal scheduler. Please contact Development IT Solutions (bert.roefs@dits-sa.com) in case of any uncertainty.");
                    return false;
            }

            // above are only two checks, but others are imaginable as well

            // include PostNuke base api
            include 'includes/pnAPI.php';

            // start PostNuke
            pnInit();

            // log in as user scheduler
            pnUserLogIn(_SCHEDULERUSER, _SCHEDULERPASSWORD);

            // do whatever you want to do as a user


    I probably stole some of this from the scheduler module I referred to above.
  • what i think would be neat is to not only be able to add/modify jobs on the server but to be able to schedule module functions as well, so a module (not the cron module) could create a job when it is initiated, and have a function in the modules code and the cron job would just hit that function based on its schedule.

    this could be done without cron to get the same results but it would require sufficiently high traffic on the site because the scheduled tasks couldn't be run without users being on the site. if you see my meaning, thats why i would like to see/make a module to allow for actual cron. i could see it being a very useful tool in zikula, not just for the module itself but for other modules which could implement it.
  • Whether you invoke what you call from a UNIX crontab or from a block (or whatever else is dependent on traffic to run) shouldn't matter in terms of what you call (pnModFunc).

    I'd recommend not requiring any modifications to existing modules. You could perhaps think of listing (extracting from module files) available user / user API / admin / admin API functions of other modules. Or you could offer a 'new task' interface listing available modules, their function types, and provide 'free text' parameter arrays. Just a few thoughts.
  • Whatever module functions you call, you need to think about what permissions are required. That's why mumuri remarked that 'users without login' should be fine, but users that require certain permissions ... .

    Cron type of functions would often admin type of functions. If you invoke a cron module based of access of an anonymous visitor you sort of need to 'fork a separate process with a logged in administrator' to perform admin functions. Getting security and permissions right is a major issue for such a module.
  • 0 users

This list is based on users active over the last 60 minutes.