Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Hi,
I would like to create automation tool (bash file) that will run automatically in all our vnc-servers and will check by user where he has open sessions
The utility pgrep can find the process id for you based on your search criteria.
Code:
pgrep -x vnc -u $user
That will give you a list of the process ids for the processes with the exact name "vnc". Which VNC server are they running, that will tell you which name to look for.
The utility pgrep can find the process id for you based on your search criteria.
Code:
pgrep -x vnc -u $user
That will give you a list of the process ids for the processes with the exact name "vnc". Which VNC server are they running, that will tell you which name to look for.
The name might not be **exactly** vnc. Remove the -x (check man pgrep)
Check with: ps ax|grep vnc
Welcome to Linux! (IF you want, tell us a tiny bit about your 'distro', &Linux goals/interest)
p.s. A different idea/concept (see man ...): netstat -tap |grep vnc
(grep vnc /etc/services) Enjoy!
I'm familiar with what u suggested I will explain what I need
I need to create a script that will check in multiple servers if there is session for specific user
Ok. Then you can find just the PIDs of the instances of Xvnc by using that exact name in your query:
Code:
pgrep -u avihuh -x Xvnc
As Jjannel suggest, perusing the manual page for pgrep can be a good idea. The -x will require an exact match but that is eventually what you need to avoid false matches.
Ok. Then you can find just the PIDs of the instances of Xvnc by using that exact name in your query:
Code:
pgrep -u avihuh -x Xvnc
As Jjannel suggest, perusing the manual page for pgrep can be a good idea. The -x will require an exact match but that is eventually what you need to avoid false matches.
actually my need is the session number, and I need it in multiple servers this command is for specific server
Oh! I'm learning here! I *wrongly* thought you meant PID (by "session number"). This search:
vnc "session number"
A question on the "multiple servers": did you want this to run *from* a 'master' [server],
or did you want this to run 'autonomously' on all systems? (Do you want to collect the results?)
I'm thinking of concepts like nagios (tho I don't know nagios), vs. [topic search]:
"run command on multiple systems"? (like via ssh; do you have this setup already?)
Oh! I'm learning here! I *wrongly* thought you meant PID (by "session number"). This search:
vnc "session number"
A question on the "multiple servers": did you want this to run *from* a 'master' [server],
or did you want this to run 'autonomously' on all systems? (Do you want to collect the results?)
I'm thinking of concepts like nagios (tho I don't know nagios), vs. [topic search]:
"run command on multiple systems"? (like via ssh; do you have this setup already?)
Best wishes... Let us know how it goes...
run from master server
collect the results
we already have multiples vnc servers here
and there are cases that someone forgot his port or event server so with that script I will be able to locate
Oh, I see now! I see *two* pieces to work on here:
1) get it working locally (research/web-search: get vnc session info)
(`vncserver -list` ?)
2) How will you 'access' the *multiple* other servers?
(do you have this setup/working already? [for any/simple-test command])
Best wishes.... Hopefully other LQ'ers, with more expertise on this than me, will come along.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.