Scan time limit

From Wordfence Documentation
Jump to: navigation, search

Some options combined with a large number of files can make scans take a long time, especially on slower servers. You can set a limit for how long Wordfence scans will run on your site. The option is called "Time limit that a scan can run in seconds." and it's available on the Wordfence Options page in the section "Scans to include". Leaving this option blank will allow Wordfence to use the default limit.

If your site reaches this limit during a scan, you will see a message in the scan results like:

Scan terminated with error: The scan time limit of 3 hours has been exceeded and the scan will be terminated. This limit can be customized on the options page.

If this happens, then the scan stops and reports the issues it has found so far, but the remainder of the scan will not be able to run unless you make some changes to scan options or the site's files. This issue will remain listed in the scan results until a successful scan has been completed without reaching the time limit.

Resolving the issue

You can adjust some options to help scans complete more quickly, look for reasons that might cause the long scans, or increase the time limit, as described below.

Scan images, binary, and other files as if they were executable

This option can be disabled if you have many non-PHP files being scanned. This option is off by default, but you may have enabled it on your site. If you have limited memory on your site but also have an exceptionally large amount of images (for example 50,000 on a fast server, or even just 5,000 on a much slower server) turning this option off may be necessary.

Exclude files from scan that match these wildcard patterns

You can add files, directories, or patterns to the "Exclude files from scan that match these wildcard patterns" box on the options page, to prevent them from being scanned. This can be useful if you keep large files within your site's folders, such as backups.

Additionally, we recommend saving backups somewhere other than in your site's own folders. In addition to saving time in scans, if the host had a major problem with the server and the whole site was lost, it is best to have your backups stored somewhere else.

Scan files outside your WordPress installation

If you have "Scan files outside your WordPress installation" enabled, you can disable it to scan fewer files. If you have additional non-WordPress applications installed, or additional sites in subdirectories of the main site (such as on some shared hosting plans), they will not be scanned if this option is disabled. If the additional sites also run Wordfence, their scans will still run normally.

Error logs

Check the error logs generated by your site. It's possible that a conflict with another plugin, a database issue, or settings on the server may be interfering with the scans, causing them to take longer than they should. Wordfence may be able to locate the error log for you. If so, you will be able to see the path to your error logs and download them from the Wordfence Diagnostics page (found on the Tools menu) in the section "Log Files (Error messages from WordPress core, plugins, and themes)".

Time limit that a scan can run in seconds

You can set this option to a longer duration, if you want scans to run for a longer time. Many hosts have limits on resource usage, especially on shared hosting plans, so it is generally best to reduce usage rather than increasing the limit.


See also: Time limit that a scan can run in seconds (Wordfence options)