is it possible to check when i recycled the app pool last time, i want to check the date when my app pool was last recycled, is there anything in IIS i can get this info.
-
Put logging statement in Application_Start in Global.asax, that is programatically. Event Viewr will be a nice place to look if you have no access to code.[This article](http://blogs.msdn.com/b/johan/archive/2008/02/18/monitoring-application-pool-and-application-restarts.aspx) explain how to set up application restart event logging – Emmanuel N Dec 14 '11 at 20:47
-
1I asked a [similar question](http://stackoverflow.com/questions/5443356/how-to-tell-why-an-iis-application-pool-is-recycled) which may be useful if you're in a shared hosting environment where you can't access the event log. – Drew Noakes Aug 07 '12 at 10:36
6 Answers
You could easily find the latest recycle time by using this powershell snippet:
(Get-Process -Id <ProcessId>).StartTime
Therefore find the process id of your web application in task manager.
First add the following columns via Tools > Select columns... : select PID and Command Line.
Look for any w3wp.exe process and find your application by examining the command-line (application pool name is part of it) and note down its PID.
Then run the powershell script to find the latest recycle time:
Hope this helps

- 776
- 1
- 6
- 6
-
An alternative to having the find the process ID is using the IIS snapin, and saying: dir IIS:\AppPools\_APPNAME_\WorkerProcesses. – nmunson Jan 22 '13 at 18:57
-
5
-
9As a one-liner: `ps w3wp | select ProcessName, StartTime` on PS v4. – Christopher Stevenson Jun 27 '16 at 21:27
-
2`ps w3wp | select ProcessName, Id, StartTime | ft -AutoSize` to display also the id of the process – krlzlx Aug 23 '16 at 10:14
-
1Thanks everyone, I used this to determine that the recycling was causing one of our App Pools to become unresponsive for ~ 3 hours once it started. The error was with w3wp.exe and module ntdll.dll, it was spotted because we were grabbing stress test data overnight monitoring server resources and saw a huge dip, which returned once the recycling completed (or the previous idle timeout was reached). Work around is to simply disable recycling, or set to specific times as to not affect clients. – TSga Nov 16 '17 at 20:24
-
I don't know why StartTime is given as an answer, this gives the timestamp of when the app pool first got up - after an iisreset for instance - not when it was last recycled. Multiple recycles do nothing to this value. – Nuno Miguel Fonseca Jul 19 '18 at 08:47
-
If logging on recycles is turned on you can see this in the Event Viewer (System Log).
If it's not you can use PerfMon counters to see Process-Elapsed Time on the W3WP.exe representing your application pool (which will be the number of seconds since the last recycle)

- 1,616
- 16
- 14
-
7Where in the Event Viewer? The `Application` logs? `System` logs? Somewhere else? – deadlydog Jan 26 '17 at 22:35
-
-
2
To get all the information with one command use the Get-WmiObject instead of get-process.
Get-WmiObject Win32_Process -Filter "name = 'w3wp.exe'" | Select-Object Name, @{"name"="ApplicationPool";expression={(($_).CommandLine).split('"')[1] }},@{"name"="Starttime";expression={$_.ConvertToDateTime($_.CreationDate)}}

- 171
- 1
- 4
In Powershell:
(ps -id (Get-IISAppPool -Name <name>).WorkerProcesses.ProcessId).StartTime
If the pool has been recycled, then for some reason you may need to re-import the module to get the new processId:
$pool = Get-IISAppPool -Name <name>
$pool.recycle()
Import-Module -Force IISAdministration
(ps -id (Get-IISAppPool -Name <name>).WorkerProcesses.ProcessId).StartTime

- 1,847
- 23
- 19
-
good, and to escape the app_pool name just wrap it with single quotations – Adel Mourad Feb 02 '21 at 13:56
This will give you a list of all the w3wp processes on the machine and their start times. The ErrorAction prevents the commandlet from throwing an error if no websites are started and therefore no w3wp processes exist
ps w3wp -ErrorAction SilentlyContinue | select ProcessName, StartTime
Tested on Server 2012 R2 with powershell v4.0

- 751
- 8
- 15
Get the worker process uptime(Recommended):
$poolName = <your pool name goes here eg. DefaultPool>
$poolProcess =(gwmi -NS 'root\WebAdministration' -class 'WorkerProcess' | select AppPoolName,ProcessId | Where-Object { $_.AppPoolName -eq $poolName } )
$lastStartTime=(Get-Process -Id $poolProcess.ProcessId).StartTime
write-output $lastStartTime
For it to work, make sure you have 'IIS management scripts and tools' enabled.
Second, way is using Event log, if enabled
Get-Eventlog -LogName system -Newest 1 -Source "WAS" -Message "*recycle of all worker processes in application pool '$poolName'*")
With Get-Eventlog
you can use -After/-Before
argument to further limit the result.
To check if Application pool is recycled in last 'X' minutes, following powershell snippet can be used:
function isRecycledInLastNMinutes($appPoolName, $lminutes){
$beforeDate = Get-Date -format 'u'
$afterDate = $beforeDate.addMinutes(-$lminutes)
$result = (Get-Eventlog -LogName system -Newest 1 -Source "WAS" -After $afterDate -Before $beforeDate -Message "*recycle of all worker processes in application pool '$appPoolName'*")
if( $result.length -eq 1){
return $true
}else{
retrun $false
}
}

- 133
- 1
- 8