When there shall be no sheriff or undersheriff in any county, it shall be the duty of the county clerk to exercise all the powers and duties of the sheriff of such clerk’s county until a sheriff be elected or qualified. When the sheriff for any cause shall be committed to the jail of such sheriff’s county, the county clerk shall be keeper thereof during the time the sheriff shall remain a prisoner therein.