Also, if it's run out of cron, there's no need to do the emailing in
perl, as cron jobs can email their output. Several distributions have
some premade directories to make it easier, like /etc/cron.hourly and
/etc/cron.daily. I'd just drop a script in /etc/cron.daily that outputs
what I want, then make sure that root's email gets to me. If you're not
the admin of the machine, you'll probably need to make your own
crontab(5), with 'crontab -e'. The man page is very helpful :)
-Tim
On Mon, 2003-08-11 at 06:46, John Hebert wrote:
> I think cron would be a better way to handle it, as putting the function in
> the bot would mean that a Perl script would have to run all the time. It
> seems you would simply be shifting the functionality from cron to your perl
> bot. However, if that's what you need, then something like:
>
> while 1
> {
> sleep(60);
> $CurrentTime = GetCurrentTime();
> $TargetTime = "16:20";
> if $CurrentTime = $TargetTime then
>
> (your code here)
>
> end if;
> }
>
> might work, though be aware that you will need to make your script sleep
> most of the time for CPU performance reasons. I suggest 60 seconds, so it
> should only run at the specified minute.
>
> The function GetCurrentTime() would have to be written of course. I don't
> know how to format the perl command localtime to return the current time in
> a "00:00" format; I'm still waking up. :)
>
> The localtime command is described here:
> http://www.perldoc.com/perl5.8.0/pod/func/localtime.html
>
> There are lots of ways to do this, and surely better ways. Maybe some real
> Perl geek could help out...
>
> John Hebert
>
>
> -----Original Message-----
> From: Wade
> To: [email protected]
> Sent: 8/11/03 6:32 AM
> Subject: [brlug-general] perl bot
>
> Maybe someone on the list can help me with this,
> I wrote a perl bot that i need to email nightly stats.
>
> Here is the section that does the emailing,
>
> if($email == 1) {
> $sender = Mail::Sender->new({
> smtp => "$mailserver", from => "$fromaddy"});
> $sender->MailFile({to => "$toaddy",
> subject => 'DroneBot update',
> msg => "Up-to-date Drones killed.",
> file => "$logfile"});
> }
> else { _END_ };
>
> What do i need to add for this to run at a certain hour.?
> I know i can make it a separate file and run a cron, but i need it built
> in the bot.
>
> Thanks
> Wade
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://brlug.net/mailman/listinfo/general_brlug.net
>
> _______________________________________________
> General mailing list
> [email protected]
> http://brlug.net/mailman/listinfo/general_brlug.net