-1

I have process1 running on one machine and generating some log file. Now I want to launch a another process which can be on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process one on terminal from which process2 is launched.

Process2 will be invoked as follows: process2 -dir "DirPath". In this DirPath process1 has written a file which has information like "pid of process1", "hostname of process 1" and "log file of process1". So process2 can access this file and has all the information about process1. Now process2 wants to know if process1 is currently running or not And if it is running then it needs to stream data written by process1 in logfile to the terminal from which process2 is launched.

Saurabh
  • 51
  • 5
  • 2
    You need some sort of agent on the first machine that will report the state of process1 over the network. There are a number of choices to be made relative to particular constraints that you might have. Be more specific. – Dima Chubarov Jun 02 '12 at 05:09
  • Process1 can write some file in a directory which process2 can access and can know the process id and host machine on which process1 is running. Using process Id and hostmachine of process1 how process2 can know whether process1 is running or not. But I need to handle all sorts of exits of process1 including kill -9. – Saurabh Jun 02 '12 at 05:46
  • "Some file in a directory" does not help you, since it's on another machine. – Ignacio Vazquez-Abrams Jun 02 '12 at 05:51
  • 1
    Like `ssh remote fuser /path/to/log` you mean? – tripleee Jun 02 '12 at 05:53
  • Process2 will be invoked as follows: – Saurabh Jun 02 '12 at 06:04

1 Answers1

1

Use ssh to logon to a remote machine and a run a script to detect if the process is running using ps and grep command and then read the log file as you know the path. In case you dont want to manually enter the password you can use the ssh key as mentioned here

Abhijit-K
  • 3,569
  • 1
  • 23
  • 31