هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
tail prints the last 10 lines of a file. With -n you choose how many. With -f (follow) it keeps the file open and prints new lines as they come: the classic way to watch a log while you test something.
-F is like -f, but it also keeps working when the log file is rotated (renamed and recreated).
طريقة الكتابة
tail [OPTION]... [FILE]...الخيارات 13
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 11
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1The last 10 lines
tail /var/log/messagesThe newest events of a log.
2The last 50 lines
tail -n 50 /var/log/secureRecent logins and sudo use.
3Watch a log live
tail -f /var/log/messagesPress Ctrl+C to stop. Open it in a second terminal while you restart a service.
4Follow a log that is rotated
tail -F /var/log/httpd/access_logKeeps following when logrotate makes a new file.
5Watch several logs at once
tail -f /var/log/secure /var/log/messagesA header shows which file each line comes from.
6Watch only errors
tail -f /var/log/messages | grep --line-buffered -i error--line-bufferedmakes grep print each line at once.7Everything from line 100 to the end
tail -n +100 big.logSkip a header or the first part.
8Remove the header line of a CSV
tail -n +2 export.csv > data-only.csvStarts at line 2.
9Stop following when a process ends
tail -f build.log --pid=$(pgrep -n make)Ends by itself when the build is done.
10Follow failed SSH logins live
tail -F /var/log/secure | grep --line-buffered "Failed password"Live view of a brute-force attack.
11Watch a deployment log in a container host
tail -f /var/log/containers/web-*.logSame idea works for any app that writes to files.
لا يوجد شيء يطابق هذا الفلتر.
انتبه
- On RHEL, many services log only to the journal. If a file in /var/log stays empty, use
journalctl -f. tail -fon a rotated file stops showing new lines; use-F.
نصائح للحفظ
tail -f= live.tail -F= live, survives rotation.tail -n +2= skip the first line.