My friends and I use the day number as part of our server rules, so we want to keep the day from changing while we're offline, but the only way I know of to do that is to stop the server from running...

4 Answers 4


You should be able to use command blocks to automatically detect whether players are online or not, then appropriately set the doDaylightCycle rule appropriately. Try placing the following setup in the server spawn chunks:

enter image description here

(Piston is a sticky one.)

The general idea is that the left command checks for online players a few times every second and the comparator next to it will only output a signal if there is at least one player online. Once everyone logs off, the piston retracts and turns off the day/night cycle. As soon as someone logs in again, the comparator will turn on again and toggle the day/night cycle back on.

  • Beat me to it. Nonetheless, good answer; +1.
    – RavenM
    Aug 18, 2015 at 23:45
  • 3
    You should be able to replace the torch/repeater/solid block setup with a redstone block on the sticky piston.
    – MrLemon
    Aug 19, 2015 at 8:58
  • I was worried that would just trigger both commands on each update, but after testing it, replacing the solid block with a redstone block does indeed work. Aug 19, 2015 at 10:00

As an alternative to @SpectralFlame's solution that works with a setblock/fill clock (for reduced lag), you can use the following two commands (in this order):

gamerule doDaylightCycle false
execute @p ~ ~ ~ gamerule doDaylightCycle true

The second command will fail when there is no player to execute on, meaning the result of the first command won't be immediately overridden.

  • I might not be understanding something, but wouldn't a fill clock contribute to more lag since you'd be executing the commands 3-5 times as often? Or is redstone lag just THAT bad? Aug 19, 2015 at 10:06
  • @SpectralFlame IIRC the main problem with redstone lag are the many block and lighting updates. Compared to that, a simple gamerule change, even when done 40 times a second, should not affect the game at all.
    – MrLemon
    Aug 19, 2015 at 12:44
  • In addition to that, using the Repeat and Chain type command blocks introduced in the latest snapshot/1.9 removes the need for the fill clock as well, making it both easier to use and probably even more lag-free.
    – MrLemon
    Aug 20, 2015 at 7:33

If you are on version 1.8+ (which i suspect you are, for you have not specified any version) then the following will help:

When the last person gets off the server, they should type the command /gamerule doDaylightCycle false this will stop the sun/moon from moving.

When the first person gets back online, you can do /gamerule doDaylightCycle true to start it back up.

Otherwise, you can put command blocks with these commands in them in an admin-only spot where you people will go when the last/first person gets on/off.


What kind of server are you running? By default most servers will keep the sawn chunk loaded all the time.

I think this may work, but I haven't actually tested. If you are running a server that supports adding the Multiverse-Core then you can change the option keepSpawnInMemory to keep the spawn chunks loaded. I suspect, but am not certain, that if no chunks are loaded then they time would basically stop.

  • 5
    I'm pretty sure that keeping (or not keeping) spawn chunks loaded does not stop the daylight cycle.
    – Judge2020
    Aug 18, 2015 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .