Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

help with screen

Name: Anonymous 2012-12-02 15:40

I am using screen like any sane person to run a few processes on a server that I want to run in the background but still have access to.

Now here is my question.
I would like to be able to create a script that automates the creation of named screen processes, but when I run the script again it kills the previous screen by that name and starts a new instance of it.  How would I go about doing this?  What specific flags/options should I be using?

Other info:
the server is running ubuntu 12.04 minimal install
only have SSH access due to it being located in Germany.

Name: Anonymous 2012-12-11 0:12

pretty sure you just add a killall <nameofscreenprocess> to the start of the script

Name: Anonymous 2012-12-12 19:20

Hm.

Well, making the screen is easy: screen -dm <command>

The PID of that screen session is now stored in $!. Store it somewhere (/tmp/blah.pid maybe?), check for it on script startup, and act accordingly.

So pseudocode would be something like this:

if /tmp/blah.pid exists
kill `cat /tmp/blah.pid`
rm /tmp/blah.pid
screen -dm <command>
echo $! > /tmp/blah.pid

Don't change these.
Name: Email:
Entire Thread Thread List