Monitor and Restart Process

Medium Shell OS
Solve this problem

Write a shell script that monitors a process by name and restarts it if it exits. Log restart time into restart.log.

Constraints

  • Use pgrep to detect running.
  • If not running, restart and log.
  • Loop with sleep 2.
  • Use while true.
Starter codeShell
1#!/bin/bash2# TODO