Running screen command for different users at startup
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.)
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.