Last active
February 14, 2017 07:08
-
-
Save fty4/cca7c0615bcb53adf7c6284df8a6c11b to your computer and use it in GitHub Desktop.
How to run a backgroundjob with screen by script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
programname=MyAppName | |
start() | |
{ | |
screen -dmS $programname /path/to/executeable.sh start | |
} | |
stop() | |
{ | |
screen -X -S $programname quit | |
} | |
status() | |
{ | |
screen -list $programname | |
} | |
show() | |
{ | |
echo -e "\e[7m$programname>\e[27m Detach with STRG + A, STRG + D" | |
echo "[waiting 2 seconds...]" | |
sleep 2 | |
screen -r $programname | |
} | |
case $1 in | |
start|stop|status|show) "$1" ;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 start|stop|restart|status|show" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment