Michael,

I use the WS (Windows Scheduler) extensively on several machines many
times daily. I have scripts that run every 15 minutes, 30 minutes,
hourly, daily, monthly, etc. I find I get the best mileage from creating
a batch-file that contains the execution of the program and its
parameters and then have the WS call the batch-file. I will sometimes
abstract this a little farther for logging purposes by having the WS
call a batch-file (parent) that calls another batch-file (child). The
contents of the parent would look something like this:

    C:\Batch_Files\DailyTasks_Stub.bat 1>C:\Temp\DailyTasks.log 2>&1
    exit 1

This way I can redirect the output of the entire child batch-file to a
single log-file and group multiple programs/tasks in the child
batch-file.

Note you can specify a context for the job to start in, i.e. a specific
directory, in the properties of the scheduled task. Also, you will need
to set the appropriate password for the task. One special note on
passwords, if you change the password of the machine that will schedule
the tasks, you will need to also go into the scheduled tasks and change
the passwords of each task. There may be a way around this, but I am
unaware of how to do this otherwise. We change passwords on a regular
basis, so this comes into play for us. You might also try specifying
full path/UNC-names for everything, including Perl, the Perl script,
etc.:

    C:\perl\bin\perl.exe C:\somedirectory\yourprogram.pl "arguments"

Note that when paths/filenames are specified that contain embedded
spaces, its best to enclose the entire string in quotation marks, i.e.:

    C:\perl\bin\perl.exe C:\somedirectory\yourprogram.pl "c:\program
files\test\some log file directory\log.txt"

Let me know if you need any other specifics.

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michael D Schleif
Sent: Wednesday, August 24, 2005 10:51
To: perl-win32-users mailing list
Subject: cron for windows ???

We have a script that runs as expected from CLI.  Basically, it parses
logfiles, and prepends to another logfile one line of summary.  Very
basic, very simple stuff.

We want it to run once per day at a specified time.  It runs on a
Windows Server 2003 box.  Windows Scheduler is very flaky on this box --
sometimes it runs the script, sometimes not.  When it does run the
script, it runs as expected.

I have googled for cron implementations for windows, and I found these:
- cronw <http://sourceforge.net/projects/cronw>
- cron  <http://www.kalab.com/freeware/cron/cron.htm>

Clearly, these are two completely different implementations, one Perl
and the other compiled.  Both fail to successfully run our script,
apparently failing for same reasons.

Unfortunately, I do not understand why the code succeeds from CLI and
fails from these cron's.  Here is the first point of breakage in the
code:

    -f $out_file
        or die "\n\tERROR: *NOT* a file: \'$out_file\'\n\n";

I have simplified this, with same failure:

    -f $out_file and die;

Earlier code defines:

    my $out_dir = "P:/Backup";
    my $out_file = "Tape_Slot.log";
    $out_file = $out_dir . '/' .  $out_file;

Yes, I am aware of issues with forward & backward slashes; and issues
with single & double quotes.  No, I have NOT found any combination of
these characters that allow cron to successfully execute this code.
Also, remember, the existing code runs exactly as expected from CLI.

I will gladly publish more code, and try suggestions, if requested.  At
this point, I am trying to present the succinct case, and plead for your
kind assistance.

What do you think?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to