How can I tell whether a process is invoked via an agent or when logged in?

user1074593 asked:

I am using a certain tool which executes via an agent on the Linux servers. We could execute it manually by logging into the Linux servers too.
I am trying to figure out (via Linux shell script) whether a user is logged in or whether the process is being invoked via the agent. Depending on this I want to execute different parts of the code.

Is there a variable in linux which helps ascertain this ?

My answer:

Try using pstree --show-parents on the process ID. This will tell you what process started the program.

For example:

$ pstree -s 18445

$ pstree -s 21797

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.