LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-08-2013, 04:52 AM   #1
Alvin88
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Rep: Reputation: Disabled
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?

Last edited by Alvin88; 04-09-2013 at 06:17 AM.
 
Old 04-08-2013, 09:05 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
I'd recommend using absolute paths for all those cmds and lose the '^M', that's an MSWin line ending.
 
Old 04-09-2013, 05:02 AM   #3
Alvin88
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
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?
 
Old 04-09-2013, 06:20 AM   #4
Alvin88
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
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.

Last edited by Alvin88; 04-09-2013 at 06:23 AM.
 
  


Reply

Tags
local, screen, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] easiest way to make things autostart in KDE? newbiesforever Linux - General 1 01-11-2011 04:07 PM
KDE 4 Autostart Program Bash Script to Write Autostart Bash Scripts for You! jdmcdaniel3 Suse/Novell 1 05-03-2010 06:17 AM
how to make programs autostart in KDE, using Konqueror newbiesforever LinuxQuestions.org Member Success Stories 1 03-15-2010 09:06 AM
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
AutoStart a Script extremebfn Slackware 2 09-11-2004 09:25 PM


All times are GMT -5. The time now is 03:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration