This (very) short story is Ray Bradbury's "The Pendulum", originally published in 1939.
You can read the full text online here
Day after day the robots still came, worked, unabated by the
visitation of the black horde. They came every week, brot food,
tinkered, checked, oiled, cleaned. Up and down, back and forth—THE
... a thousand years must have passed before the sky again showed life
over the dead Earth. A silvery bullet of space dropped from the
clouds, steaming, and hovered over the dead city where now only a few
solitary robots performed their tasks. In the gathering dusk the lites
of the metropolis glimmered on. Other automatons appeared on the
rampways like spiders on twisting webs, scurrying about, checking,
oiling, working in their crisp mechanical manner.
And the creatures in the alien projectile found the time mechanism,
the pendulum swinging up and down, back and forth, up and down. The
robots still cared for it, oiled it, tinkering.
A thousand years this pendulum had swung. Made of glass the round disk
at the bottom was, but now when food was lowered by the robots through
the tube it lay untouched. Later, when the vacuum tube came down and
cleaned out the cell it took that very food with it.
Back and forth—up and down.
The visitors saw something inside the pendulum. Pressed closely to the
glass side of the cell was the face of a whitened skull—a skeleton
visage that stared out over the city with empty sockets and an
enigmatical smile wreathing its lipless teeth.