LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to make an autostart script with screen sesion (https://www.linuxquestions.org/questions/linux-general-1/how-to-make-an-autostart-script-with-screen-sesion-4175457321/)

Alvin88 04-08-2013 04: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:

Code:

cd /opt/directory
Code:

screen -S 0
Code:

./run.sh
So, the idea is that script run.sh 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:
Code:

cd /opt/directory && screen -p 0 -X stuff './run.sh^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 09: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 05: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 06: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.
Code:

cd /opt/directory && /usr/bin/screen -s /bin/bash -dmS XHSS ./run.sh
Small description:
-s /bin/bash - is the name of the SHELL to run it.
XHSS - name of the screen session
./run.sh - 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 07:44 PM.