Validators must be online 24/7. Otherwise, they face ejection and loss of rewards as a result of liveness failure. Failure to participate in consensus for one era results in ejection.
If you cannot run a node 24/7, you can delegate your tokens to a healthy validator node with good uptime to earn rewards. Delegating to a validator will earn you the same rewards as running a validating node, minus the fee/"commission" the validator charges for their service (typically 0-10% of rewards).