Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Clear-Host
- #$repeat="Y"
- $count = 0
- $last_restart = 0
- $restart = 0
- do {
- if((get-date).hour -eq 0 -and (get-date).minute -eq 0)
- {$count = 0 #reset the restart counter at midnight every day
- write-host "________________________"}
- if((get-process jrun|select -exp workingset64) -gt 3900MB)
- {get-process jrun | stop-process
- $count++
- write-host "Jrun restarted: " -nonewline; Get-Date | write-host
- write-host "count: " $count
- $last_restart = $restart
- $restart = get-date
- $a= (Get-Content E:\server\path\test_log.txt)[-1].Split("`t")
- write-host $a[1].Trim() "broke the page!" #for testing
- $smtpServer = "192.168.0.1"
- $MailFrom_ = "iwebmaster@domain.com"
- $msg_ = new-object Net.Mail.MailMessage
- $smtp_ = new-object Net.Mail.SmtpClient($smtpServer)
- $msg_.From = $MailFrom_
- #$msg_.To.Add("it@domain.com")
- $msg_.To.Add($a[0].Trim())
- $msg_.Subject = "Problem with submission"
- $MailTextT_ = $a[1].Trim() + ", the process needed to be restarted on the web server. If your pages did not download completely, please reduce the number of pages to process in this batch. You may need to download them individually and OCR with eCopy. If you received all of your pages, then you may disregard this message."
- $msg_.Body = $MailTextT_
- $smtp_.Send($msg_)
- Start-Sleep -s 30
- }
- else
- {Start-Sleep -s 30}
- if(($count -eq 10) -and ($last_restart.month -eq (get-date).month -and $last_restart.day -eq (get-date).day))
- {
- $smtpServer = "192.168.0.1"
- $MailFrom = "iwebmaster@domain.com"
- $msg = new-object Net.Mail.MailMessage
- $smtp = new-object Net.Mail.SmtpClient($smtpServer)
- $msg.From = $MailFrom
- $msg.To.Add("it@domain.com")
- $msg.Subject = "Potential issue on web"
- $MailTextT = "PS script has killed jrun 10 times on web in the last 24 hours!"
- $msg.Body = $MailTextT
- $smtp.Send($msg)
- $count = 0
- write-host "________________________"
- $last_restart = $restart
- $restart = get-date
- }
- }
- while (1 -eq 1)
Add Comment
Please, Sign In to add comment