Nightwatchman is a term referred to a lower order batsman who comes in to bat out of his turn towards the end of the day's play in the longer version of the game.
In case a wicket falls with just a few minutes of play left (10-20 minutes), then the captain opts to send in a lower order batsman ahead of the regular batsman. Now this option of sending in a nightwatchman is undertaken with a view of protecting the new batsman.
Normally, with just a few minutes left for the end of play, if a regular batsman goes he will not be in a position to play his natural game, as the team would not like to lose another wicket and hence he will be forced to play cautiously and under a great deal of pressure, which might, paradoxically, lead to another wicket. So to avoid this, a lower order batsman is sent - more like a sacrificial lamb - to ward off the last few overs of the day by just blocking away at the balls, so that the regular batsman can start a fresh on the morrow.
However, the nightwatchman may not succeed all the time. It's a chance the captain takes and it may or may not pay off. But on most occasions it pays off. In fact, there are occasions when the nightwatchman, after surviving the day, continues to offer resistance on the morrow and ends up building a healthy partnership, which in turn ends up irking the opposition.
Note: After the closure of an innings if the other team is asked to bat for 15 minutes, however less the amount of time there are no nightwatchmen for openers, At least so far that has been the case - given that there is always a first.