Martin McCormick wrote: 
> Greg Wooledge <wool...@eeg.ccf.org> writes:
> > I was vaguely thinking of a similar approach.  Set up a job that runs
> > every hour, or across a set of hours that will cover all the possible
> > cases that you care about, in your crontab.  Within the job itself,
> > set a TZ variable and determine the time in that time zone by whatever
> > means necessary, and then either abort or continue based on that time.

This approach:

- does not replace crond, and so does not screw up upgrades to
  the next version of Debian

- is a small, useful utility which could be adopted rapidly and
  later packaged for Debian

- can be ignored by people who don't need it.

>       Crontab would have a new field at the beginning of each
> line which could normally be left at "default" which would be the
> normal behavior that we are used to.

This approach requires one of:

- convince the upstream maintainer of cron to adopt it

- convince the Debian maintainer of cron to adopt it as a patch
  that gets applied and potentially broken/fixed on each release

- creates a new cron package in competition with the existing
  one

- creates a local cron package that has to be maintained along
  with upstream changes


The third approach would be to build cronie for Debian, which is
probably do-able but is nevertheless a competitor for cron and
faces similar issues.

>       I haven't looked at the C code for cron, but I have
> written a few perl scripts that do things with time and dates and
> the current epoch-based number of seconds since utc Midnight January
> 1, 1970 is based on the C modules such that one's current
> wall-clock time is time(localtime).  Just a thought

Perl is definitely an appropriate language for a utility
like this.

libdatetime-timezone-perl
libtime-parsedate-perl
libdatetimex-easy-perl

are all extremely common installs. 

As a name for the utility, I suggest "do-if-time-in" and require
three parameters:

do-if-time-in timezone time "command"

As an interim fix, though: (and I know Greg's going to fix this)

---
#!/bin/bash
TZ=$1
NOW=$(date +%H%M)
echo $NOW
if [ "$2" = "$NOW" ]  ;
    then echo $("$3")
fi 
---

-dsr-

Reply via email to