First post and apologies for the formatting but I'm on mobile.
I wish I could remember the name of this short story, because it is unbelievably emotionally strong. SciFi. Humans had fought a war with an alien race and it ended without resolution. The enemy just pulled back. But it had been a near thing so a number of warning stations were set up in deep space so that humanity would have a warning. They were heavily armed and mostly automated with just a couple of men manning them.
The plan was that if they detected the enemy, they'd send the warning and a ship would evacuate them. In this story, on one station, one of the crew had a fall and died, leaving one man alone. After a long time alone, he detected the advancing enemy. They were coming in large numbers and faster than expected. The assault was going to hit them before they could be evacuated and they were given orders to fight and hold out for as long as they could, but there could be no relief as the ships would be dealing the enemy that got through.
It's been a long time since I read this, but this soldier had grown afraid that his station was haunted. He would feel a presence, a movement in the corner of his eye. And as the enemy approached, and he got the word that he was to fight and die, he felt despair that he would die alone. At that moment, the ghosts he'd been afraid of became more visible and concrete. A soldier in helmet with a rifle. A Spartan with shield and spear. A dozen or more. And the Spartan turned to him and said, "Brother, you do not stand alone. We are here, your brothers who also stood and died, holding the line against an enemy who was overwhelming. We stand with you, and when your time comes and you fall, you will join us...to stand with the next soldier who holds the line...not alone.