start some actions with Perl without Cron?

P

PHP2

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?
 
K

krakle

PHP2 said:
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?
 
S

Sherm Pendley

PHP2 said:
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--
 
B

Ben Morrow

Quoth (e-mail address removed):
It is spelled wrong.

IIRC 'cron' has nothing to do with 'chron-', but actually stands for
'commands run overnight' or some such...

Ben
 
J

Jürgen Exner

PHP2 said:
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
 
S

Sara

PHP2 said:
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
 
M

Mark Bole

Sara said:
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
 
C

ctcgag

PHP2 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top