/usr/bin/rtail is in ruby-file-tail 1.1.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/usr/bin/ruby
require 'file/tail'
require 'tins/go'
include Tins::GO
require 'thread'
Thread.abort_on_exception = true
$opt = go 'n:m:Mh'
if $opt['h']
puts <<EOT
Usage: #{File.basename($0)} [OPTS] PATHES
OPTS are
-n NUMBER show the last NUMBER of lines in the tailed files
-m PATTERN only tail files matching PATTERN, e. g. '*.log'
-M prefix every line with the logfile name
-h to display this help
EOT
exit
end
dirs, logfiles = ARGV.partition { |path| File.directory?(path) }
$n = ($opt['n'] || 0).to_i
$logfiles = File::Tail::Group.new
def add_logfiles(logfiles)
logfiles = logfiles.map { |l| File.expand_path(l) }
$opt['m'] and logfiles =
logfiles.select { |l| !$opt['m'] || File.fnmatch?($opt['m'], File.basename(l)) }
for l in logfiles
$logfiles.each_file.any? { |f| l == f.path } and next
warn "Tailing '#{l}'."
$logfiles.add_filename l, $n
end
end
add_logfiles logfiles
t = Thread.new do
$logfiles.tail do |line|
if $opt['M']
puts "#{line.file.path}: #{line}"
else
puts line
end
end
end
begin
loop do
logfiles = []
for d in dirs
logfiles.concat Dir[File.join(d, '*')].select { |x|
File.file?(x) || File.symlink?(x)
}
end
add_logfiles logfiles
sleep 1
end
rescue Interrupt
warn " *** Interrupted *** "
end
|