I am writing a script to test a handful of mail accounts on our mailserver. This script needs to run automatically every half hour on a Windows machine, unfortunately, I don't have access to cron. My questions are: Is the script below the way to do this? and; Can anyone recommend a better method?
#!/usr/bin/perl -w use strict; use MIME::Lite; use Date::Calc qw(Today_and_Now Date_to_Text_Long); my $gmt; my $sleeptimer; my ($year,$month,$day, $hour,$min,$sec) = Today_and_Now([$gmt]); my $sig = "\n\nHere is my sig"; my $time = sprintf("%s, %s:%s:%s", Date_to_Text_Long($year,$month,$day), $hour, $min, $sec ); my $msg = MIME::Lite->new( From =>'test@account.com', To =>'test1@account.com', Cc =>'test2@account.com, test3@account.com', Bcc =>'test@account.com', Subject =>'This is a test message', Data =>"This message was sent from my script:\n\n +$time$sig" ); if ($min > 30) { $sleeptimer = 60 - $min; $sleeptimer = $sleeptimer * 60; } elsif ($min < 30) { $sleeptimer = 30 - $min; $sleeptimer = $sleeptimer * 60; } else { $sleeptimer = 1800; } if ($sleeptimer ne 1800) { sleep $sleeptimer; } do {$msg-> send('smtp', "mail.server.com", Timeout=>60); sleep 1800; redo; }
Edited: Retitled

In reply to cron (scheduling) Mail job under Windows by BigRare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.