I have moved!

Wednesday, April 18, 2007

Checking if a screen session is already running, keeping it alive

I'm somewhat new to screen and bash-scripting and was looking for how to keep one of my screen sessions alive even after a system reboot. I tried searching on Google, but had a hard time finding exactly what I wanted. This is what I ended up with using cron:

Made a check script:
#!/bin/bash
foo=`screen -ls | grep -c autostart.screen`
if [ "$foo" -eq "0" ]; then
/usr/bin/screen -dmS autostart.screen /usr/bin/irssi -c freenode
fi
I named it checkIrssi.sh and made it executable with:
chmod 755 checkIrssi.sh
Then I put up a cron using "crontab -e" to run the script every hour:
* */1 * * * ~/path/to/checkIrssi.sh
And badabing!

1 comment:

SEO Company Bangalore said...

Awesome good way to find and thanks for sharing.