HNHacker News
TopNewBestAskShowJobs

_iyrr

1 karma · joined November 21, 2022

submissionscomments
_iyrr··on Ask HN: What was your “why didn't I start doing this sooner” moment?
Many ways to accomplish the same thing in Linux, starting with a popen() call. ;) so thanks for pointing out tmux.

Since I use screen fairly often, it had never occurred to me (until fairly recently) that you can rely on it to start with a machine reboot -- and yet have the very familiar interface available to you when you want to intervene. Something to be said about muscle memory.

_iyrr··on Ask HN: What was your “why didn't I start doing this sooner” moment?
Using screen in daemon mode.

    screen -dmS myservice /blah/start.sh
Fit that line somewhere in a properly constructed init.d file and you're good to go. And if you need to execute a safe stop from that program through some interactivity:

    screen -S myservice -X stuff "stop\n"
And voila. It sends a line of text over followed by an enter key. Elegant, useful. You can reattach session to see what's happening at any time. Love me some screen.

When the process exits in that screen session, screen session is closed so that you can rely on screen -list.