tail utility doesn't work as expected


New Member
Sep 18, 2019
Reaction score

I start monitoring is process alive using tail utility by
tail -Fn0 --pid=11111 /opt/mylogfile.log

Process with PID 11111 was restarted and now this process has other PID 22222 but I still see that tail continue monitoring for process with PID 11111. Could it be a tail issue? Icheck /proc and failed to find /proc/11111. May be tail just hangs?

The files in /proc aren't always "normal" files.

Normally you don't "tail" a process. You want to tail output from a file (usually one that has streaming input).

tail -f /opt/mylogfile.log is probably what you want to do here.

Every time a process is restarted it will have a different process ID. That is normal.
There is no way to always make a process start with the PID.

Usually applications have "pid" files. Normally created in /run or /var/run.
Example: /var/run/nginx

All that is in this file is a PID (process ID) that might look like 7615 or 11111,
but it will change every time you stop and start the service.

Probably the easiest way to tell if a process is running, is by 'grep'ing the name of the process.

ps -ef | grep nginx

Just replace nginx with whatever process you are looking for.

Members online