You can use the following script to auto restart the nginx on the server. The following script check the status and…