Cron jobs, background methods
Jim Adamek (7/22/08 11:43AM)
Ben Kershaw (7/22/08 8:02PM)
arnaud (7/22/08 8:24PM)
Chip Scheide (7/23/08 12:57PM)
Ben Kershaw (7/23/08 1:21PM)
Jim Adamek (7/22/08 11:43 AM)
Hello,
How do you set up cron jobs or background methods that run at regular
time intervals on 4D Web Server?
Thanks,
Jim Adamek
Ben Kershaw (7/22/08 8:02 PM)
Cc: jim@...
Jim Adamek wrote:
"How do you set up cron jobs or background methods that run at regular
time intervals on 4D Web Server?"
You have a few options. You can use a stored procedure on the server
that pauses until it is time to run, and then goes back to sleep until
it is time to run again. Simple to do, but it can be a pain if (when)
you need to change the timing. Also a pain if you have multiple jobs
to run.
A have a client that runs about 30 timed processes; some hourly,
others daily, and others weekly. Instead of writing procedures to
handle the timing, I just use cron and have it kick off the 4D
procedure. Why write code that has already been written, debugged, and
is built into the OS?
In my case I have the cron job create a file with a timestamp in a
folder that 4D watches. When 4D sees the file, it parses the job name
from the file and runs the job. This way, if 4D is down the files
still get created, and I can handle the jobs in order or skip them if
a certain timeout has been reached on a per job basis.
You can either use this file method, or have the cron job kick off a
shell script that either hits 4D via AppleScript (using osascript),
however I had problems passing parameters to the shell script via cron
and having those parameters passed to 4D.
Another way would be to have the shell script call a web service on
the server; I'm not sure if you can do this with a shell script, but I
wouldn't be surprised if you could. In a pinch, perhaps curl would
work. You would be requesting a page (URL) from the server, but in
reality you'd just be trapping for that URL in 4D and running the job.
A bit of a hack, but it would work.
In my case I wanted as few moving parts as possible, and the file
method worked perfectly and has been for the past year.
Regards,
Ben Kershaw
arnaud (7/22/08 8:24 PM)
Jim Adamek a Ècrit :
Hello,
How do you set up cron jobs or background methods that run at regular
time intervals on 4D Web Server?
I use a stored procedure (named deamon, very original) to do this. It
sleeps very often, and when not sleeping looks what jobs have to be
launched (other stored procedures). It does nothing else (error codes
must never stop the deamon, so it uses short and simple code).
--
Arnaud de Montard
Chip Scheide (7/23/08 12:57 PM)
Cc: jim@... 4D iNug Tech <4d_tech@...
On Wed, 23 Jul 2008 12:49:19 -0400 (EDT), Ben Kershaw wrote:
http://www.google.com/search?hl=en&q=cron+windows&btnG=Google+Search
And by "other OSes", you mean "Windows only" - right?
Yes -
and you can always be sure that Cron for windows exists on each and
every PC your software is installed on right?
Ben Kershaw (7/23/08 1:21 PM)
Cc: Chip Scheide <4d_Only@...
On Wednesday, July 23, 2008 12:57pm, "Chip Scheide"
<4d_Only@... said:
On Wed, 23 Jul 2008 12:49:19 -0400 (EDT), Ben Kershaw wrote:
http://www.google.com/search?hl=en&q=cron+windows&btnG=Google+Search
And by "other OSes", you mean "Windows only" - right?
Yes -
and you can always be sure that Cron for windows exists on each and
every PC your software is installed on right?
Most cron jobs (or at least those I've worked with) run on one "robot"
machine, or on the server. But, point taken - if you need to run cron
jobs on every machine, then it would be a hassle to make sure the
Windows cron software is installed. Not as easy as installing 4D
Client on all those machines, to be sure, or adding code to make sure
the right job runs on the right machine, should you go the "all 4D
code" route, or allowing for duplicate machine names on different
subnets....
Hmm... seems like in that case (cron jobs on every machine),
installing the cron software is actually easier. Meh - maybe not.
But neither is it "failing entirely".
Regards,
Ben Kershaw
Reply to this message
Summary created 7/23/08 at 5:22PM by Intellex Corporation
Comments welcome at: feedback@intellexcorp.com