In WordPress 3.0 wp_maintenance() function introduced to die with a maintenance message when conditions are met. You need to create a file .maintenance in the WordPress root directory. In this file, you need to add variable $upgrading and set to the time the file was created. If the file was created less than 10 minutes ago, WordPress enters maintenance mode and displays a message.
You can also display maintenance message more than 10 minutes by adding following code in .maintenance file.
<?php $upgrading = time();
Here, we’ve set current time in $upgrading variable. So WordPress will display maintenance message until you delete .maintenance file.
In WordPress 4.6, enable_maintenance_mode filter introduced to enable/disable maintenance mode. This filter runs before it can be used by plugins. It is designed for non-web runtimes. If this filter returns true, maintenance mode will be active and the request will end. If false, the request will be allowed to continue processing even if maintenance mode should be active.
Default maintenance message is Briefly unavailable for scheduled maintenance. Check back in a minute. The default message can be replaced by using a drop-in (maintenance.php in the wp-content directory).