Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How to schedule an activity on Windows using Perl?

by imperl (Novice)
on May 09, 2005 at 10:27 UTC ( [id://455134]=perlquestion: print w/replies, xml ) Need Help??

imperl has asked for the wisdom of the Perl Monks concerning the following question:

How can I schedule (say the execution of a particular file), at a specified time and day, on Windows? Eg. Execute the file, file1.bat every 10 minutes starting at 3 am on 25th May, 2005 to 3am, 25th May,2005. Is this possible?
system("file1.bat")

Replies are listed 'Best First'.
Re: How to schedule an activity on Windows?
by gellyfish (Monsignor) on May 09, 2005 at 10:36 UTC

    Windows has a built in scheduler similar to cron on Unix like systems, you can use this. If you want to control this via a Perl program (otherwise this would not be a perl question) you can use Win32::TaskScheduler.

    /J\

      Im aware of the Task Scheduler in Windows but the problem is that I have around 500 files that need to be executed an Im hoping to write a Perl script to automate this, if possible. Yes, schedule all at different times. Thanks.
        Do you need to schedule all those 500 files during differrent times? Then I would suggest you to script it (in Perl, of course).
        If not, then the simplest way would be to add all those files (500 or how-much-ever) in a batch file (In DOS, you name the file with the extn '.bat'). You can then schedule this batch file using the Windows Scheduler or the Perl Module.


        Cheers,
        Rupesh.
Re: How to schedule an activity on Windows using Perl?
by Anonymous Monk on May 09, 2005 at 13:38 UTC
    Hi imperl

    I’m a big fan of cronw.
    I use it on a daily basis to run bat and perl scripts.

    Below is an example of the cron file syntax for running bat and perl scripts jobs on WinXP.
    Adding or changing a job is simply a matter of editing the cron text file.
    #-------------------------------------------------------------------- # Run a perl script at 06:04 and 16:04 each day. #-------------------------------------------------------------------- 04 6,16 * * * C:\perl\bin\wperl.exe C:\Perl\_scripts\a_perl_script.pl #-------------------------------------------------------------------- # Run a bat script at 08:01 and 17:01 each Friday. #-------------------------------------------------------------------- 01 08,17 * * 5 C:\WINNT\system32\cmd.exe /c "C:\a_bat_script.bat" #--------------------------------------------------------------------
    Dave :-)
Re: How to schedule an activity on Windows using Perl?
by aditya.singh (Acolyte) on Jun 16, 2005 at 12:28 UTC
    Control Panel->Schedule Tasks->Add new task.
    Simple enough?
      Don't you have to set it up in a batch file?

      Ex: run_me.bat with content below?

      C:\perl\bin\perl myperlscript.pl

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://455134]
Approved by polettix
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found