Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Schedule Win32 Perl Scripts with AT

by ybiC (Prior)
on Dec 04, 2002 at 21:31 UTC ( #217597=perlmeditation: print w/ replies, xml ) Need Help??

Introduction

at.exe is a commandline scheduler on Win32, similar in concept to *nix cron and at.   It's run from a cmd.exe window, and allows you to add, remove, and view scheduled commands.   Other tools exist for MS-Windows scheduling, but are outside the scope of this document.

Examples

(at time /date command)

at 2:00 /every:Th C:\Perl\bin\perl.exe C:\perls\foo.pl --options --and --arguments

at 14:00 /next:T C:\Perl\bin\perl.exe C:\perls\foo.pl --options --and --arguments

Caveats

    Perl-Specific

  • at.exe evidently runs in an environment with no path to perl.exe.   Therefore the script must be called in this form: drive:\path\to\perl drive:\path\to\script.pl

    General

  • cmd.exe commands apparantly cannot exceed 256 characters.   See Win32::AdminMisc below to get around this.
  • at.exe is included only in true 32bit versions of MS-Windows (NT, 2k, XP), and isn't part of 16bit versions of MS-Windows (3.(0|1)|9(5|8)|me).   If one of the latter group is your development platform, you have my deepest condolances.   %^P
  • Mistakes in this doc are quite possible - corrections, additions, and rotton kiwifruit welcome.   Well, maybe not the rotton fruit.

See Also

    PerlMonks

    Roth

    ActiveState

    CPAN

    Microsoft support

    Local help

  • at /?

Thanks to a monk or three (you know who you are) for pre-post critique, who shall remain nameless lest the sins of this post be visited upon them verily unto three generations

Update: thanks to to replying monks for pointing out what appears to be substantial problems with win32 at.   I've not encountered problems myself, but have no reason to doubt that they exist.   Please, read the rest of this thread for yourself *before* using my examples in any situation that's at all important.   Caveat Usor

Comment on Schedule Win32 Perl Scripts with AT
Select or Download Code
Re: Schedule Win32 Perl Scripts with AT
by dws (Chancellor) on Dec 04, 2002 at 21:44 UTC
    <rant>
    at is @#^$%& broken. To compare it to cron(8) is an insult. It unschedules tasks at the faintest whiff of trouble. (Don't dare let your tasks fail, or they go into the great unscheduled limbo.) This is especially problematic if you're trying to deal with a network share that's periodically unavailable.

    If you start trying to use at, do yourself a favor and make a batch file to reschedule your jobs, since you'll find yourself rescheduling them again and again and again and ...
    </rant>

      If you do it "again and again", then shouldn't you just schedule that rescheduling with at?

      An oft-used technique to work around some of those problems is to schedule a wrapper batch that invokes the real task.

      The wrapper task always succeeds, regardless of whether the real task does or not, thereby bypassing some of the problems. I used to have a fairly elaborate .cmd file that would also reschedule itself (with the name of the passed real command to be run) every hour 5 minutes etc if your needs are for a smaller granularity than daily.

      I might be able to dig a copy out if anyone was interested.


      Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
      Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
      Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
      Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Re: Schedule Win32 Perl Scripts with AT
by simon.proctor (Vicar) on Dec 04, 2002 at 23:01 UTC
    I've had no end of trouble with at on NT (et al) so I simply create a bat file using pl2bat and use the task scheduler if available.

    On windows advanced server (where I do most of my work) I can set up the program to run as any user I like from within the task scheduler so can avoid having to put my credentials into the Perl source if it is required to have them.

    I don't recall 98 (haven't used it in ages) but task scheduler is also available on WinMe for those unfortunate enough to own it. If you do use WinMe then you won't have the credential possibilities for obvious reasons.

    Just an alternate solution :)
      Task Scheduler ships with IE 5 for those using 9x.

      --
      I'm not belgian but I play one on TV.

Re: Schedule Win32 Perl Scripts with AT
by Marza (Vicar) on Dec 05, 2002 at 04:49 UTC

    As the others have basically stated; I found AT unusable for a project I had.

    Roths stuff is good as long as you don't try it on W2K. From what I have been told is that he is way too busy to keep things current these days.

    One nice little prize I found on sourceforge is TaskScheduler. It is being developed but I found it usable and the author is very interested in making it work.

    So if you want a good alternative, give it a look!

    TaskScheduler
Re: Schedule Win32 Perl Scripts with AT
by YordanGeorgiev (Novice) on Jan 07, 2007 at 19:52 UTC

    I had to develop a comparably complicated perl based scheduler running on Windows used for running QA GUI scripts. Some points :

    1. Use perl2exe in order to generate the executables - not need to deploy Perl to all workstations (if you have them more ; )

    2. Do not put all the eggs into one basket - one executable starting the daily cycle and rebooting according to the times in the settings file

    3. Produce different executables for the Daily Cycle, Hourly cycle .. etc.

    4. Timing related code into a Timer.pm - array of hashes to store the dynamicly generated times according to the cycle length

    5. Process handling and killing - in separate modules

    6. Do not use fork , use CAREFULLY perl threads combined with

    use Win32::Process ; Win32::Process::Create( $proc_o, "$proc_path", "" , 0, CREATE_NO_WINDOW ,$dir_where_to_run);

    7. Use a simple xml file in order to keep track of the whole system

    8. Many other small tricks - send me e-mail First.Last@gmail.com if need more information

    9. The whole think has worked already 4 months 24/7 without any serious failures ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://217597]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-12-19 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (75 votes), past polls