CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Use of schedule::cron module

 



mmcw2201
User

Sep 10, 2002, 2:59 AM

Post #1 of 12 (4771 views)
Use of schedule::cron module Can't Post

Someone told me to use the schedule::cron module when it is not possible to use cron. I did install the module but do not know how to use the module. What lines do I have to add to my perl script?

This is what I want:
I want to run every day at 08.00 the perl script: www.test.com/cgi-bin/test.pl?action=test.

Optional I want to read the time and to excecute program from a file ( like in the real cron)

How to do that with the schedule::cron module.
I did read the documentation but I stiil do not kown what to do?


thebitch
User

Sep 10, 2002, 4:03 AM

Post #2 of 12 (4769 views)
Re: [mmcw2201] Use of schedule::cron module [In reply to] Can't Post

http://www.test.com/cgi-bin/test.pl?action=test

is not a mere perl script.

It's a server application, and as such, you cannot run it.

You need to execute a program on your machine
to make a GET HTTP Request to that URL,
like a web browser would.

you can do this from perl by using LWP,
and in particular the commandline utility GET
that comes with it

As for Schedule::Crong,
all you need to know is contained in the pod

http://search.cpan.org/author/ROLAND/Schedule-Cron-0.05/Cron.pm


davorg
Thaumaturge / Moderator

Sep 10, 2002, 5:29 AM

Post #3 of 12 (4768 views)
Re: [mmcw2201] Use of schedule::cron module [In reply to] Can't Post

I've not used the module myself, but the documentation seemed clear and detailed.

What part where you having trouble with?

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


(This post was edited by davorg on Sep 10, 2002, 8:00 AM)


mmcw2201
User

Sep 10, 2002, 7:30 AM

Post #4 of 12 (4765 views)
Re: [davorg] Use of schedule::cron module [In reply to] Can't Post

I have tried something like this:

use Schedule::Cron;

my $dispatcher = sub {
print "\n";
print "ID: ",shift,"\n";
print "Args: ","@_","\n";
};

sub update_currency {
# do something...
do "http://www.test.com/cgi-bin/ShopSecure/shop_admin.cgi?action=update_correction&use_cron=1";
}

my $cron = new Schedule::Cron($dispatcher);

$cron->add_entry("0-59/10 * * * *",\&update_currency);

# Run scheduler
$cron->run();

But this will not run the do command! I want to run every 10 minutes the sript given in the do command. Wat am I doing wrong and how to make it work!


mmcw2201
User

Sep 10, 2002, 7:32 AM

Post #5 of 12 (4764 views)
Re: [thebitch] Use of schedule::cron module [In reply to] Can't Post

Could you help me a little bitt further:

I nwo tried this:

use Schedule::Cron;

my $dispatcher = sub {
print "\n";
print "ID: ",shift,"\n";
print "Args: ","@_","\n";
};

sub update_currency {
# do something...
do "http://www.test.com/cgi-bin/ShopSecure/shop_admin.cgi?action=update_correction&use_cron=1";
}

my $cron = new Schedule::Cron($dispatcher);

$cron->add_entry("0-59/10 * * * *",\&update_currency);

# Run scheduler
$cron->run();

This without success! How to make it work?


mmcw2201
User

Sep 10, 2002, 9:43 AM

Post #6 of 12 (4759 views)
Re: [thebitch] Use of schedule::cron module [In reply to] Can't Post

thebitch:

The program I want to start is at my own server!

the path is/path/to my/server/cgi-bin/test.pl.


mmcw2201
User

Sep 12, 2002, 11:24 PM

Post #7 of 12 (4754 views)
Re: [davorg] Use of schedule::cron module [In reply to] Can't Post

Davorg or The Bitch or someone else:

Can you help me with my problem?


Paul
Enthusiast

Sep 13, 2002, 3:52 AM

Post #8 of 12 (4744 views)
Re: [mmcw2201] Use of schedule::cron module [In reply to] Can't Post

Please continue your posts here.


Quote
Does anyone know (and is working with) the module schedule::cron?

My provider will not allow me to use crontabs. That's why I want to use schedule::cron. I read the documentation and tested a few thing but all without success!

This is what I want:

I want to start every day at 08.00 the following perl script: www.test.com/cgi-bin/test.pl?action=do.

How to set this up?

Also I read it should be possible to check what processes are started by schedule::cron. How to check that?

How to stop a schedule::cron task (or stop all started schedule::cron tasks?

Michel



(This post was edited by RedRum on Sep 13, 2002, 3:52 AM)


thebitch
User

Sep 13, 2002, 4:32 AM

Post #9 of 12 (4737 views)
Re: [mmcw2201] Use of schedule::cron module [In reply to] Can't Post

please use [code][/code] tags when posting code.

now, read perldoc -f do.

do does not do what you want

if the script is on your server,
then why are you typing a http://blah....?

If you do that, then it's like it's not on your server

if you're gonna persist with the http://
you'll need to use LWP::Simple::get (or something from LWP).

It looks like what you really want is
system or exec, as in

Code
exec('/full/path/to/cgi-bin/ShopSecure/shop_admin.cgi...')


But i'm not quite sure that's true, cause I know nothing about shop_admin (it's either one or the other)

perldoc is your friend ;)


mmcw2201
User

Sep 13, 2002, 10:41 AM

Post #10 of 12 (4730 views)
Re: [thebitch] Use of schedule::cron module [In reply to] Can't Post

I have the following code:

I simple uploaded the cron.pm file to a Sub dir called Schedule to the directory '/home/cgi-bin/Shop/Modules'.




Code
   

#!/usr/local/bin/perl -w

use lib '/home/cgi-bin/Shop/Modules';
use Schedule::Cron;

my $dispatcher = sub {
exec('/home/cgi-bin/ShopSecure/shop_admin.cgi?action=update_correction&use_cron=1');
};

my $cron = new Schedule::Cron($dispatcher);

$cron->clean_timetable();

# Trie to run the script every ten minutes.
$cron->add_entry("0-59/10 * * * *");
$cron->run;

1;



You can see it at:

http://m-scripts.hypermart.net/cgi-bin/Shop/cron.pl

However the scripts starts and waits a long time after it will stop.

Nothing happens and the shop_admin.pl script will not start!

What am I doing wrong. I am using a free hypermart server! Can it be that it isn't possible to run this script/ module there?


mmcw2201
User

Sep 13, 2002, 10:45 AM

Post #11 of 12 (4729 views)
Re: [thebitch] Use of schedule::cron module [In reply to] Can't Post

I get at the end the following error

/home/cgi-bin/ShopSecure/shop_admin.cgi?action=update_correction: not found

However when I test for the existens of the file by using:

print "wwwwwwwwwwww" if -e '/home/cgi-bin/ShopSecure/shop_admin.cgi';

it does find the file (it prints wwwwwwwwwwww)?????


mmcw2201
User

Sep 13, 2002, 10:52 AM

Post #12 of 12 (4728 views)
Re: [thebitch] Use of schedule::cron module [In reply to] Can't Post

I tried it once moer and got a lot of errors in my error log:


Code
 MainLoop - next: Fri Sep 13 10:50:00 2002 in malloc(): warning: recursive call. 
Out of memory!
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in malloc(): warning: recursive call.
Out of memory!
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.
MainLoop - next: Fri Sep 13 10:50:00 2002 in free(): warning: recursive call.etc........... MainLoop - next: Fri Sep 13 10:50:00 2002 in malloc(): warning: recursive call.Out of memory!


What does that mean?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives