Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Last active March 29, 2016 12:24
Show Gist options
  • Select an option

  • Save PieterScheffers/9532ff8cc1de91fabbdf to your computer and use it in GitHub Desktop.

Select an option

Save PieterScheffers/9532ff8cc1de91fabbdf to your computer and use it in GitHub Desktop.
Screen start stop
### Start screen session ###
# http://stackoverflow.com/questions/7049252/how-to-create-a-screen-executing-given-command
function exec_in_screen() {
name=$1
command=$2
screen -dmS $name sh; screen -S $name -X stuff "$command\n";
}
exec_in_screen "test" "ls"
# start gulp watch in screen session
screen -dmS gulp_watch sh;
sleep 2;
screen -S gulp_watch -X stuff "gulp watch\n";
screen -dmS gulp_watch sh; screen -S gulp_watch -p 0 -X stuff "gulp watch\n";
### Stop detached screen session ###
# http://stackoverflow.com/questions/1509677/kill-detached-screen-session
# stop gulp watch in screen session
screen -X -S gulp_watch quit
screen -S gulp_watch -p 0 -X quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment