2012-12-12

Detached Screens

If you want to start something automatically, you can use these commands either after logging in (user startup) or without logging in (system startup). But what if you want to run something from init.d/, you're going to have to exec it as a specific user. See my previous post on NCDC to see why anyone would ever need that. First off, I had to find out how I'd start a detached screen and execute a command. That was pretty easy:
screen -dmS screenname command
But since I wanted to create an init.d/ script, I had to change the user with su first - or even better, just execute a command as the user. This executes a screen as user username, which executes command in it. CMDEXECCEPTION OMG.
su -c screen -dmS screenname command username
Have fun! :)