I think I read it in Omni, but I’m not sure. Could have been in one anthology or another.
A large cube is found on the Moon. When an astronaut enters it, he is killed in some way. Scientists have come up with a way of duplicating humans by storing their ‘essence’ on disc. So when the astronaut dies he is ‘rebooted’ and retains the memories up to the moment of his death. The astronaut goes into the cube, remembering what killed him before, and makes it a little farther… But he’s killed again. This is repeated over and over until the goal is achieved. I don’t remember if they ever found out what the cube was for, other than it was some sort of lab-rat experiment.