It is the duty of the sheriff in whose custody the defendant is at the rendition of the judgment, or afterwards legally comes, to execute the judgment of imprisonment by committing the defendant, as soon as possible, to jail, or to the warden of the penitentiary, according to the exigency of the writ.