Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]8391[/thread]

Wachsenden Dateien folgen: tail -f (Seite 3)

Leser: 2


<< |< 1 2 3 4 >| >> 34 Einträge, 4 Seiten
ptk
 2006-10-07 12:30
#70532 #70532
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
[quote=betterworld,07.10.2006, 02:33][quote=sid burn,07.10.2006, 02:17]Ansonsten halte ich jedes BSD für Konservativ. Kein System V. Nur ein Startskript. ;)[/quote]
Das stimmt ja gar nicht. FreeBSD hat einen ganzen Haufen Startskripte unter /etc/rc.d.[/quote]
Das ist aber neu, bei FreeBSD 4.x gab es das noch nicht. FreeBSD 5.x habe ich übersprungen, FreeBSD 6.x hat tatsächlich einen Haufen davon. Und weitere in /usr/local/etc/rc.d.
sid burn
 2006-10-08 20:02
#70533 #70533
User since
2006-03-29
1520 Artikel
BenutzerIn

user image
So,
eine Lösung mit Linux::Inotify2 könnte folgendermaßen ausschauen:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use warnings;
use strict;
use constant TRUE => 1;
use constant FALSE => 0;
use Linux::Inotify2;
use IO::Handle;

open my $fh, '<', $ARGV[0] or die "Cannot open file: $!\n";
$fh->blocking( FALSE );

my $inotify = new Linux::Inotify2 or die "Unable to creat Linux::Inotify2 object: $!\n";
$inotify->watch( $ARGV[0], IN_MODIFY, \&file_changed ) or die "watch creation failed";
sub file_changed {
while ( sysread $fh, my $buff, 50 ) {
syswrite STDOUT, $buff;
}
}

print <$fh>;
1 while $inotify->read;
close $fh;


Ich habe auf der Suche auch folgendes Modul von Michael Schilli gefunden:
File::Tail::FAM

Allerdings lies sich das bei mir nicht Compilieren. Hab das ganze jetzt aber auch nicht mehr weiter verfolgt.


Jetzt müsste ich nur noch hinbekommen, dass nicht die ganze Datei ausgegeben wird, sondern beim start nur die letzten 10. Jemand Ideen wie ich das am besten anstelle?\n\n

<!--EDIT|sid burn|1160324864-->
Nicht mehr aktiv. Bei Kontakt: ICQ: 404181669 E-Mail: perl@david-raab.de
esskar
 2006-10-08 20:26
#70534 #70534
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
naja, mit seek ans ende springen und suchen.
bloonix
 2006-10-08 21:19
#70535 #70535
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hallo Sid,

es sollte natürlich noch ein wenig mehr können... das tail -f in Perl :-)

Wenn zum Beispiel ein Logrotate dazwischen funkt und die Datei
packt, sollte das Skript sowas mitbekommen und die neue Datei
"tailen". Eventuell mit einer Option, die dem Skript mitteilt, dass sowas
passieren könnte...

Gruss,
opi
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
esskar
 2006-10-08 21:24
#70536 #70536
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=opi,08.10.2006, 19:19]Logrotate[/quote]
OT: danke, sowas hab ich gesucht!

Gruss,
ein Linux-Neuling
betterworld
 2006-10-09 07:43
#70537 #70537
User since
2003-08-21
2613 Artikel
ModeratorIn

user image
[quote=opi,08.10.2006, 19:19]Wenn zum Beispiel ein Logrotate dazwischen funkt und die Datei
packt, sollte das Skript sowas mitbekommen und die neue Datei
"tailen". Eventuell mit einer Option, die dem Skript mitteilt, dass sowas
passieren könnte...[/quote]
By the way, "tail -F" ist fast wie "tail -f", ist aber gegen logrotate immun.
bloonix
 2006-10-11 00:45
#70538 #70538
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=esskar,08.10.2006, 19:24]
OT: danke, sowas hab ich gesucht!

Gruss,
ein Linux-Neuling[/quote]

OT2: unter /etc/cron.* gibt es so einiges, was ein Linuxsystem auf Trab
hält und aus /etc/crontab initialisiert wird... ist auf jeden Fall einen Blick
Wert =)
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
bloonix
 2006-10-11 00:50
#70539 #70539
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=betterworld,09.10.2006, 05:43]By the way, "tail -F" ist fast wie "tail -f", ist aber gegen logrotate immun.[/quote]

Japp, stimmt!

Code: (dl )
1
2
3
4
tail -F foobar
test
tail: "foobar" has been replaced; following end of new file
test


Code: (dl )
1
2
3
4
echo test >>foobar
mv foobar foobar.1
touch foobar
echo test >>foobar


Mir wäre besser geholfen, wenn ich öfters mal einen Blick in die
Manpage werfen würde! :-)\n\n

<!--EDIT|opi|1160513476-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
esskar
 2006-10-11 01:48
#70540 #70540
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=opi,10.10.2006, 22:45][quote=esskar,08.10.2006, 19:24]
OT: danke, sowas hab ich gesucht!

Gruss,
ein Linux-Neuling[/quote]

OT2: unter /etc/cron.* gibt es so einiges, was ein Linuxsystem auf Trab
hält und aus /etc/crontab initialisiert wird... ist auf jeden Fall einen Blick
Wert =)[/quote]
naja, es hat mir doch nicht geholfen. ich musste auf
cp foo bar && > foo zurückgreifen!
bloonix
 2006-10-11 11:13
#70541 #70541
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=esskar,10.10.2006, 23:48]naja, es hat mir doch nicht geholfen. ich musste auf
cp foo bar && > foo zurückgreifen![/quote]
Kommt darauf an, was du machen möchtest... ein "copy" ist je nach Größe der Datei auch keine gute Lösung, erstmal dauert so ein copy-Vorgang und es wird der doppelte Platz benötigt. Ein mv + touch (oder >) ist um einiges schneller. Um sicherzustellen, dass die Datei nicht im Zugriff ist, gibt es fuser.
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
<< |< 1 2 3 4 >| >> 34 Einträge, 4 Seiten



View all threads created 2006-10-06 00:49.