Home > Archive > PERL Miscellaneous > August 2004 > start some actions with Perl without Cron?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
start some actions with Perl without Cron?
|
|
|
| is possible start some actions with Perl without Cron?
for example send email to users from database after 3 days or delete
something from database automaticaly after 3 day with Perl but without Cron?
| |
|
|
| krakle 2004-08-22, 3:56 am |
| "PHP2" <gp@nospm.hr> wrote in message news:<cg5u56$d6$1@ls219.htnet.hr>...
> is possible start some actions with Perl without Cron?
>
> for example send email to users from database after 3 days or delete
> something from database automaticaly after 3 day with Perl but without Cron?
What's wrong with cron?
| |
| Sherm Pendley 2004-08-22, 3:56 am |
| PHP2 wrote:
> is possible start some actions with Perl without Cron?
>
> for example send email to users from database after 3 days or delete
> something from database automaticaly after 3 day with Perl but without Cron?
If you're looking to avoid cron because you don't want to leave your
server active 24x7, you might want to have a look at anacron. It's a job
scheduler that's designed to handle downtime, by running any missed jobs
whenever the system comes back up.
Otherwise, yes, it's possible to do without Cron, but you'll end up
writing something that looks, walks, and quacks like Cron anyway. You'll
need to write a script that runs all the time, checking to see if it
needs to run any scheduled actions and then sleeping for a time before
checking again.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
| |
| Tad McClellan 2004-08-22, 8:56 am |
| Pinocchio <krakle@visto.com> wrote:
> What's wrong with cron?
It is spelled wrong.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
| |
| Jürgen Exner 2004-08-23, 3:59 pm |
| PHP2 wrote:
> is possible start some actions with Perl without Cron?
>
> for example send email to users from database after 3 days or delete
> something from database automaticaly after 3 day with Perl but
> without Cron?
You will still need something that kicks of the Perl program initially
anyway. So why not leverage cron instead of writing a similar system
yourself.
jue
| |
| Ben Morrow 2004-08-23, 3:59 pm |
|
Quoth tadmc@augustmail.com:
> Pinocchio <krakle@visto.com> wrote:
>
>
> It is spelled wrong.
IIRC 'cron' has nothing to do with 'chron-', but actually stands for
'commands run overnight' or some such...
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
| |
|
| "PHP2" <gp@nospm.hr> wrote in message news:<cg5u56$d6$1@ls219.htnet.hr>...
> is possible start some actions with Perl without Cron?
>
> for example send email to users from database after 3 days or delete
> something from database automaticaly after 3 day with Perl but without Cron?
You can "sleep" for 60 x 60 x 24 x 3 seconds. I'm not sure if that
particular integer is in the range of "sleep"; I'll leave that as an
exercise to the reader.
If that's what you mean. But you won't get the builtin advantages of
using cron like crash recovery, logging, etc.
However, on some systems the admin locks down cron with /etc/cron.deny
or allow, so occasionally you'll need to "roll your own" in those
hostile environments. I've done it, but never with such an extended
sleep time.
Personally if I was going to sleep that long, I'd be more inclined to
have a small shellscript that kicks off the Perl script every n
seconds. That way the program isn't perpetually resident (yes I'm an
old-timer!).
G
| |
| Mark Bole 2004-08-25, 3:57 pm |
| Sara wrote:
> "PHP2" <gp@nospm.hr> wrote in message news:<cg5u56$d6$1@ls219.htnet.hr>...
>
>
>
>
> You can "sleep" for 60 x 60 x 24 x 3 seconds. I'm not sure if that
> particular integer is in the range of "sleep"; I'll leave that as an
> exercise to the reader.
>
> If that's what you mean. But you won't get the builtin advantages of
> using cron like crash recovery, logging, etc.
>
> However, on some systems the admin locks down cron with /etc/cron.deny
> or allow, so occasionally you'll need to "roll your own" in those
> hostile environments. I've done it, but never with such an extended
> sleep time.
>
> Personally if I was going to sleep that long, I'd be more inclined to
> have a small shellscript that kicks off the Perl script every n
> seconds. That way the program isn't perpetually resident (yes I'm an
> old-timer!).
>
> G
Your examples all mention "database". Some databases, such as Oracle,
have a built-in job scheduler that provide capabilities similar to cron,
so you could just use that instead (portable across Windows and Unix).
There is also built-in SMTP support for sending e-mails (in Oracle).
There's also the "at" command which is still cron under the covers, but
doesn't require an entry in the crontab file. You can even have each
"at" job, as its last step, schedule another "at" job.
--Mark Bole
| |
| ctcgag@hotmail.com 2004-08-27, 8:56 pm |
| "PHP2" <gp@nospm.hr> wrote:
> is possible start some actions with Perl without Cron?
>
> for example send email to users from database after 3 days
3 days after *what*?
> or delete
> something from database automaticaly after 3 day with Perl but without
> Cron?
Well, I probably wouldn't use Cron as a general engine to do this anyway.
I don't think Cron is made to handle tens of thousands of tasks on a
one-off basis. I might use cron to fire some bulk-processing script, but
certainly not each individual action.
while (1) {
make_connection_if_not_valid($dbh);
$dbh->do('delete from foo where bar < date_add(now(),interval -3 day)');
## specifics vary with DBMS
sleep 1800;
};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
|
|
|
|
|