Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out how much SSH-connections currently exist [closed]

Tags:

linux

bash

shell

I'm using a simple Shell-script on my Linux-server which checks, if a rsync-job is running or if any client some directories from the server via Samba. If this is the case then nothing happens, but are there no jobs and no Samba is used, than the server goes into hibernate.

Is there any simple command, which I can use to check if a ssh-connection to the server exist? I want to add this to my Shell-script, so that the server doesn't go to hibernate, if such a connection exist.

like image 354
Chrispie Avatar asked Jun 19 '13 18:06

Chrispie


1 Answers

Scan the processlist for sshd:. Established connections look something like this: sshd: <username>…

ps -A x |grep sshd |grep -v grep

should work out for you.

like image 188
TimWolla Avatar answered Oct 27 '22 06:10

TimWolla