"tail" Command

The tail command is a command-line utility for outputting the last part of files. By default, it returns the last 10 lines of each file that it is given. It may also be used to follow a file in real-time and watch as new lines are written to it.

Basic Usage

$ tail nohup.out

Limit the number of lines to show

$ tail -n 5 nohup.out

Show the last 10 lines of multiple files

$ tail <file1> <file2> ...
==> <file1> <==
word1
word2
...

==> <file2> <==
word1
word2
...

To suppress the header line, which can be useful to combine files.

$ tail -q <file1> <file2>
word1
word2
...
word1
word2
...

Watch a file for changes

$ tail -f caffe.log

# and for watching multiple files
$ tail -f <file1> <file2>

Run a Command or Shell-Script after Logout

This is extremely helpful when the command takes a long time to run.

$ nohup command or ./run.sh &

Combining with "tail" command, we can watch the running process in real-time.

$ nohup ./run.sh &
$ tail -f nohup.out

Redirect output to a custom log

$ nohup ./run.sh > custom.log &

To check the processes in the background

$ ps aux | grep "run.sh"

If we want to kill the process

$ kill -9 <PID>

results matching ""

    No results matching ""