trap 'kill $(jobs -p)' EXIT funktioniert nicht.

T

TickTockMan

Grünschnabel
hallo Leute,

ich habe einen Shell Script, der mehrere tail -f tut. ungefähr so:
Code:
trap 'kill $(jobs -p)' EXIT
tail -f node1.log &
tail -f node2.log &
tail -f node3.log &

Das funktioniert soweit ganz gut. Wenn ich nun pro Logzeile noch die node-nummer haben will
Code:
trap 'kill $(jobs -p)' EXIT
tail -f node1.log | awk '{print "[1]",$0}' &
tail -f node2.log | awk '{print "[2]",$0}' &
tail -f node3.log | awk '{print "[3]",$0}' &
dann funktioniert die trap leider nicht.

Code:
(tail -f node1.log | awk '{print "[1]",$0}' ) &

funktioniert auch nicht

Meine Vermutung ist, dass neue shells gespawnt werden und dass jobs -p die nicht sieht.
(liegt es vielleicht daran, dass jobs tot ist ? ;) ;) ;) )

Hat jemand eine Idee ?

Vielen Dank schonmal !!!

PS: rksh, AIX
 
Zuletzt bearbeitet:
btw: weiss jemand eine bessere Alternative um die Ausgaben von tail -f mit einem prefix auszustatten ?
 

Ähnliche Themen

Shellskript - Fehler in Cron

Problem mit HSPA+ Modem Huawei E353 - Installation unmöglich?

Samba 4 Gast Zugang unter Ubuntu funktioniert nicht

wxPython Problem

Falsche Rechte gesetzt beim Anlegen von Ordnern via Samba-Client

Zurück
Oben