http://www.perlmonks.org?node_id=949541


in reply to Help with Perl

Hi Ashok.g,

Ok, your task can be programmed dynamicaly, but .. why don't you want to use cron (if you are in Unix wolrd)?

Two approaches:

  • Regenerate /var/spool/cron/user when you need, cron will reload in the next minute
  • Regenerate /etc/cron.d/yourtask when you need it, cron will reload it, and surely will be more readable and maybe easy to implement.
  • Of course where you write "a.pl 25" will be "*/25 * * * * /path/to/a.pl"

    So, if you are in Unix environment, why not cron ?

    Thanks

    Replies are listed 'Best First'.
    Re^2: Help with Perl
    by sundialsvc4 (Abbot) on Jan 24, 2012 at 05:24 UTC

      I gotta chime in on this one ... agreeing wholeheartedly.   Always look for the simplest available solution that leverages existing facilities.   If cron can reasonably do the job, without you creating something that will be impossible to understand three months from now, then that is probably the way that you want to do it.

      Another notion would be that you could use cron simply to execute some script at the smallest possible interval ... then maintain a list or database (SQLite?) of “what needs to be done” and “the last time it was done.”   The script simply executes each command that has come due, then exits until next time.   But, I am very reluctant to build complicated solutions to what ought to be simple, routine problems.

    Re^2: Help with Perl
    by ashok.g (Beadle) on Jan 24, 2012 at 08:36 UTC
      As I said in my post, the scripts and interval are always dynamic..... So I didn't want to always add and delete CRON entries... may be this will be my last option....
        Maybe you didn't get the idea:

        Your scheduler can be regenerate by another script which can be launch at regular intervals (by cron) or by a daemon which is always investigating if changes to scheduler are necessary

        Where does my proposition fail?