Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a bit of trouble with GNU's screen. What I want to do is this (from cron):

If a screen session named cron exists, add a new window to the session and launch a process in it (but do not attach to the session). Otherwise, create a new session called cron and launch the process in it (again, do not attach). If possible, all of this should be done using just one "screen" command.

I've already tried a bit but haven't come to a solution that satisfies all of my needs:

screen -S cron -dRRm screen ping example.com
screen -S cron -X screen ping example.com

Is there something I have missed?

share|improve this question
add comment

1 Answer

I don't think that you can do this in one command, but this should do what you want:

screen -ls cron | grep -q '(\w*tached)' >&- || screen -dmS cron
screen -S cron -X screen ping example.com
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.