-   Linux - General (
-   -   How to make an autostart script with screen sesion (

Alvin88 04-08-2013 05:52 AM

How to make an autostart script with screen sesion
Hi all,

Here is my question:
I would like to autostart script with screen session.

Here it is manual solution:


cd /opt/directory

screen -S 0

So, the idea is that script will run inside screen session. Unfortunatelly, it must be that way.

I would like to place it to /etc/rc.d/rc.local (this is Linux Centos), and start it while the whole box has started.

I tried something like:

cd /opt/directory && screen -p 0 -X stuff './^M'
and couple of other solution, which I have found using Google, but this still not work.

What I am doing wrong? How to make it work as design?

chrism01 04-08-2013 10:05 PM

I'd recommend using absolute paths for all those cmds and lose the '^M', that's an MSWin line ending.

Alvin88 04-09-2013 06:02 AM

Thanks, but it does not seems to work....

My main concern is that this script print lots of messages on the monitor -
and when I do something like 'screen -x' I cannot see those messages.

Is this correct, or not correct?

Alvin88 04-09-2013 07:20 AM

Hi all,

I manage to run it:
Place it in a file - /etc/rc.local using vi editor, at the end of the file and you are good to go.

cd /opt/directory && /usr/bin/screen -s /bin/bash -dmS XHSS ./
Small description:
-s /bin/bash - is the name of the SHELL to run it.
XHSS - name of the screen session
./ - name of the script to run when

The main problem was with my settings of .screenrc file which keeps setting for screen session.
Basically saying - I played to much with it, hence the issue.

Hope that helps.

Marking as solved.

All times are GMT -5. The time now is 05:19 PM.