Minecraft wiki entry for Things_not_to_do, associated text: disable command blocks in server properties if on a server or realms
use a program like MCEdit (for 1.12.2 and below) or Amulet Map Editor (1.12.2+) to delete the command block.