How to divide 100 by the amount of logged in users?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
How to divide 100 by the amount of logged in users?
I wrote this bash script to call another script written in C that uses threads. My dedicated server can only support 100 threads being used at one time and I am going to be having multiple users on my dedicated server. I am trying to take 100 divided by the number of users logged in to my server so that each will have a fair share of threads. Example: 4 users are logged in to my server at a given time and all 4 are running my script. Each user will have an equal amount of threads that are being used. So 100/4 would be 25 threads per user. All I am trying to do is get 100 divided by the amount of users logged into my server, what would be the best way to do this? I know the 'who' command can tell you how many users are logged in but I don't really know how to use it. This should be pretty simple for most of you guys to do, I'm a Linux newbie. Cut me some slack lol.
Using 'cut' and 'sort' takes care of users that are logged in multiple times or have multiple terminal windows open (if they are accessing your system via a GUI).
This should be pretty simple for most of you guys to do, I'm a Linux newbie. Cut me some slack lol.
I was wondering about that. You can write multi-threaded C programs, but not do simple math in the shell. Whatever, the above should work for you. Good luck!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.