cron job
Nikos Kanellopoulos
nkan at panafonet.gr
Mon Oct 18 15:40:52 EEST 2004
Giorgos Keramidas wrote:
> On 2004-10-18 15:20, Nikos Kanellopoulos <nkan at panafonet.gr> wrote:
>
>>Giorgos Keramidas wrote:
>>
>>Ο server τρέχει Vixie-Cron 3.0.1
>>Έβγαλα το σχόλιο, αλλά δεν βοήθησε.
>>Ορίστε το mail από τον δαίμονα:
>>
>>From: root at zerowing.vosn.net (Cron Daemon)
>>To: astraka at zerowing.vosn.net
>>Subject: Cron <astraka at zerowing> /home/astraka/getvotes.pl
>>2004-10-18 15:10: 1
>
>
> Τα δευτερόλεπτα όντως τα τυπώνει με κενό το vixie-cron (οπότε έχει bug)
> ή σου ξέφυγε κάτι στο copy/paste?
Όχι, έτσι τα δείχνει...
>
> Άρα το cron δεν έχει πρόβλημα. Το script σου κάνει κάποια βλακεία.
Δεν νομίζω. Άλλωστε δουλεύει από command-line. Αλλά δες και συ:
#!/usr/bin/perl
#
# Mail me last hour's votes, run as a cronjob
use DBI;
use Mail::Internet;
# data source
$db="dbi:mysql:dbname=*******" ;
# db handle
$dbh= DBI->connect($db,******,*****) || die $DBI::errstr;
($sec, $min, $hour, $mday, $mon, $year,$wday,$yday,$isdst) =
localtime(time()+9*3600);
$year += 1900;
$mon += 1;
$min = sprintf("%2s", $min);
$sec = sprintf("%2s", $sec);
$datemax = "$year-$mon-$mday $hour\:$min\:$sec";
$hour -= 1;
$datemin = "$year-$mon-$mday $hour\:$min\:$sec";
$sth = $dbh->prepare("SELECT date, photo_id, filename, rating, comment,
visitor FROM photo_ratings JOIN photos ON photos.id=photo_id WHERE DATE
BETWEEN ? AND ? ORDER BY date desc") || die $dbh->errstr;
$sth->execute($datemin, $datemax) || die $dbh->errstr;
while ( @row = $sth->fetchrow_array ) {
$tmp = (join " | " , @row)."\n";
$data = $data.$tmp;
}
if ($data != "") {
# send the mail
my $head = Mail::Header->new;
$head->add(From => 'astraka at astraka.net');
$head->add(To => 'nkan at panafonet.gr');
$head->add(Subject => 'Last hour\'s votes as of '.$datemax);
$mail = Mail::Internet->new(Header => $head, Body => [$data], Modify => 1);
$mail->send('sendmail');
}
#-----------------------------------------------------------
Δεν κάνει τίποτα σπουδαίο.
Εννοείται, ότι φροντίζω το $data να μην είναι άδειο όταν λέω ότι δεν
στέλνει mail...
Να τί μου έστειλε όταν το έτρεξα μόνος μου:
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-path: <astraka at zerowing.vosn.net>
Received: from ouranos.panafonet.gr (smtp2.panafonet.gr [213.249.17.125])
by hamail.panafonet.gr
(iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003))
with ESMTP id <0I5S00MDP4RNWW at hamail.panafonet.gr> for
nkan at panafonet.gr; Mon,
18 Oct 2004 15:16:35 +0300 (EEST)
Received: from zerowing.vosn.net (zerowing.vosn.net [209.197.232.11])
by ouranos.panafonet.gr
(iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003))
with ESMTP id <0I5S009I64S2L1 at ouranos.panafonet.gr> for nkan at panafonet.gr
(ORCPT nkan at panafonet.gr); Mon, 18 Oct 2004 15:16:50 +0300 (EEST)
Received: from astraka by zerowing.vosn.net with local (Exim 4.34)
id 1CJWRP-0003H6-OG for nkan at panafonet.gr; Mon, 18 Oct 2004 06:16:43 -0600
Date: Mon, 18 Oct 2004 06:16:43 -0600
From: astraka at astraka.net
Subject: Last hour's votes as of 2004-10-18 15:16:43
To: nkan at panafonet.gr
Message-id: <E1CJWRP-0003H6-OG at zerowing.vosn.net>
X-Mailer: Perl5 Mail::Internet v1.62
X-AntiAbuse: This header was added to track abuse,
please include it with any abuse report
X-AntiAbuse: Primary Hostname - zerowing.vosn.net
X-AntiAbuse: Original Domain - panafonet.gr
X-AntiAbuse: Originator/Caller UID/GID - [32317 907] / [47 12]
X-AntiAbuse: Sender Address Domain - zerowing.vosn.net
X-Source:
X-Source-Args:
X-Source-Dir:
Original-recipient: rfc822;nkan at panafonet.gr
2004-10-18 15:02:50 | 78 | augo085.jpg | 5.00 | |
More information about the Linux-greek-users
mailing list