Linux monitors the running shell scripts of a process and linux monitors shell scripts.
This script scans and monitors the process with the specified process name at intervals of 2. Once the process does not exist, it restarts.
#! /Bin/sh
A = 10;
While [[@ a-gt 5]; do
If test $ (pgrep-f $1 | wc-l)-eq 2; then
Sh stop. sh
Gnome-terminal-x sh start. sh &
Fi;
Sleep 2;
Done;
Conclusion: (1) & indicates that the current process starts another process to execute the gnome-terminal command; (2) if the parent process in linux crashes, the child process does not, instead, set the parent process of the child process to 1 (init process); (3) view the command jobs-l of the background running process; view the method of the parent process of process 20197, ps-ef | grep 20197.
My problem: pgrep-f $1 | the running status of wc-l in sh is different from that in the terminal. Why does the execution in sh not exist, is it 2 ?, Welcome to comments and discussions ~~
Write a program in linux to check whether a process exists. You cannot use shell scripts.
You can use pipelines or something, if. you wrote out, in. create a new pipe in out. When it starts, send a message to let B. when receiving the message from this pipeline, it means that a is started. If a. out is not written by you, then I will not, ha, hope to help you. New to LINUX
Which of the following is a shell script used in linux to monitor whether multiple processes are dead and kill and restart if they die?
I use the process that monitors a process: the "vmstat" command as an example.
#! /Bin/bash
PROSS = 'ps-el | grep vmstat | awk '{print $14 }''
STAT = 'ps-el | grep vmstat | awk '{print $2 }''
PID = 'ps-el | grep vmstat | awk '{print $4 }''
If [$ PROSS]
Then
If [$ STAT = "Z"]
Then
Echo "$ PROSS has dead"
Echo "Now, killing it"
Kill-9 $ PID
Echo "Now, restart"
Vmstat 2 5>/tmp/vmstat.txt &
Else
Echo "$ PROSS is running healthy"
Fi
Else
Echo "The programm has dropped"
Echo "Now, restart"
Vmstat 2 5>/tmp/vmstat.txt &
Fi