screen -dmS test_screen echo 'test'
Why does the screen "test_screen" exit as soon as it's "finished"? When I start a screen and then detach it manually (screen -S test_screen, then Ctrl+a d), the screen will keep existing until I exit manually. What's the difference?
SOLUTION:
Solution: start the screen first without any command:
screen -dmS screen_name
then you can run commands like this:
screen -S screen_name -p 0 -X stuff $'echo hello world\n'