Forum Discussion

deepak216632160's avatar
deepak216632160
Copper Contributor
Jan 03, 2020

task scheduling to automate send email and start the pm2 services

I have created a website named abccompany.com and used a node js with pm2 services. now I want to use task scheduled like that whenever my website goes down or services goes offline it checks for pm2 status either it is online or offline in every x seconds or minutes and automatically sends an email to admin and starts the services so that there should not be any fault tolerance when anybody reached my website. I just want all this using Power Shell and task scheduler.

 

If you find any resolution related to my query then please reply me at dpakagarwal737@outlook.com

  • deepak216632160 

    Are you looking for a starting point or a full solution?

     #Start your script with a test of services:

    $Running = get-service w3svc

    #Then do an If/Else

    If ($running.state -eq "Running") {}
    Else {Start-service w3svc ; Send-mailmessage <lookup this cmdlet and provide values for the parameters>  }

     

Resources