LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-11-2006, 07:15 AM   #1
FatOldSun
LQ Newbie
 
Registered: Feb 2004
Posts: 19

Rep: Reputation: 0
Running screen command for different users at startup


In rc.local I have added some commands to run programs in their own screen, using commands similar to the following:

/usr/bin/screen -dmS screenname ./executable-file

However all these screens run as the root user. If I login as a different user and type the same command in manually, the screen is assigned to that user only, and screen -ls only shows the user's own screen, not the others running under root's session. What I would like to do is run some of the screens at startup, as a user other than root. Is this possible, and if so how? I've read the screen manual page but it doesn't really help.

The reason I want to do this is that when the server boots up, it needs to run all the programs, however if certain users log in via SSH, I only want them to see the screens for the programs that belong to them.
 
Old 01-11-2006, 10:35 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Why not just put the commands into the user's .profiles so that it starts when they login rather than at bootup?

Adding something like:

exec command

To the end of the user's .profile will make it start "command" (which of course would be whatever application you wanted) and REPLACE the shell it started from so that when they exit the application they automatically logout. (You do it that way because simply putting in "command" without the "exec" would make it start automatically but on exit they would go to the shell prompt.)
 
Old 01-11-2006, 10:44 AM   #3
FatOldSun
LQ Newbie
 
Registered: Feb 2004
Posts: 19

Original Poster
Rep: Reputation: 0
The software has to load up at startup - it's basically a database which runs client/server which they connect to over the web using TCP/IP, however the database server has to be running for them to connect to it, and it should be running all the time from startup. However there may be times when they need to SSH in to restart the program or do an upgrade, and if there are several versions of the program running for different people, I don't want one person being able to see a list of screens for everyone else's databases, as they would then be able to go into those screens and close down the applications. I hope that makes some kind of sense!
 
Old 01-11-2006, 10:56 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Have you tried:

su - username -c "/usr/bin/screen -dmS screenname ./executable-file"

where username is the name of the user you want to have run the screen? (You may have to put in full path of "executable-file" instead of "./")
 
1 members found this post helpful.
Old 01-30-2010, 05:10 PM   #5
dragon_788
LQ Newbie
 
Registered: Jul 2003
Distribution: VMs of as many as possible, Ubuntu/openSUSE most often
Posts: 5

Rep: Reputation: 0
Thanks jlightner,

This worked like a charm in a case where I was trying to do the same thing as OP.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running a command on startup scankyfrank Linux - General 8 05-08-2005 05:03 PM
FTP Server Up and running... how do I hide ftp users from local login screen? joe1031 Mandriva 2 03-18-2005 04:24 PM
Running a command at Startup TuxTimo Linux - Newbie 6 02-27-2004 05:11 PM
Running a command on startup? flamesrock Linux - Software 5 09-06-2003 11:43 PM
Running a command in a screen session ifan Linux - Newbie 0 07-16-2003 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration