Most dehumidifiers have an automatic on / off feature. They run and remove moisture from the air until an humidity level of around 40% is achieved.
A dehumidifier can be set to run on a 24-hour basis. This is dependent on the moisture of the space, the capacity of the unit, and its built-in features. If the room is humid, you may need to leave the dehumidifier running all day.