script : How many sessions are there ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script : How many sessions are there ?
# 1  
Old 06-10-2009
script : How many sessions are there ?

Hi everybody,

I need a script that shows the total number of sessions there are ...

This shows how many sessions are open...

Code:
echo "Number of open sessions: "
  w | grep :0 | wc | awk '{print $1}

But how can I see how many sessions there are in total??
I hope someone can help me...

Grtz
# 2  
Old 06-10-2009

How do you define "session"?

What are you really looking for?
# 3  
Old 06-10-2009
Well , the code i showed, displays how many sessions the current user has opened...
What I am looking for is how many sessions there are in total...
# 4  
Old 06-11-2009
Your code counts the number of lines in a "w" display which contain the string ":0". If will give different results depending on the time of day.

Assuming a normal unix login shell and "sessions" means current active sessions:

Code:
Number of sessions from this user:

who -u|grep \^"${LOGNAME} "|wc -l

Number of sessions on the whole computer:

who -u|wc -l

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel SQL sessions in shell script

i have 3 sqls , sql 1 and sql 2 shuld run in parallel , but sql 3 should run after completion f sql1 nd sql2, my code is as below, please suggest the changes sqlplus username1/password1@DB1 @sql >> log1 & sqlplus username2/password2@DB2 @sql2 >> log1 & how can i execute the... (7 Replies)
Discussion started by: only4satish
7 Replies

2. HP-UX

Idle sessions.

What kind of problems can be faced if any session which connects to unix server is open for longer time? How to find out from how much time that session is idle? :) (1 Reply)
Discussion started by: anandgodse
1 Replies

3. Shell Programming and Scripting

Kill sessions

Hi , I am connecting to the linux redhat machine as user : APPS I would like to know how i can kill -9 , all APPS sessions beside me . Please advice Thanks (2 Replies)
Discussion started by: yoavbe
2 Replies

4. Solaris

Logging remote telnet sessions via script

Hi, My requirement - for security purpose - I want all root logins to my solaris servers are done by a script kept in a separate unix box. This script will telnet into remote solaris server with root user and log every session via log file. Now my purpose is to log every telnet session... (3 Replies)
Discussion started by: rahul_jain250
3 Replies

5. UNIX for Dummies Questions & Answers

I-node and sessions

I have a program (written by me, for educational purposes) called "analyzer". The program takes a parameter, a filename, and does some statistics on it (for example, word's number, line's number, ... ) at regular intervals. My teacher told me that if the file is edited while the "analyzer" is... (4 Replies)
Discussion started by: hurricane
4 Replies

6. Shell Programming and Scripting

Help with executing parallel sessions for same shell script with different but fixed parameters

Hi Experts, There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed. Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select... (11 Replies)
Discussion started by: Opamps123
11 Replies

7. Solaris

Switching between sessions

Unix sys admin in training here and I was performing a rollout of java code. While rolling out my connection to the server was broken. I logged back on to the box and performed a ps -ef | grep 'user' . I could see that session and pid number. My question is was there anyway to resume or... (1 Reply)
Discussion started by: vedder191
1 Replies

8. Shell Programming and Scripting

SSH sessions from bash script

Hi Forum. First of all thanks for reading. I need some help here. I have been checking some other posts about this issue, but I still have problems... I'm trying to conect througn ssh to several machines to kill some process and I have problems with the " ' ' ". This is what I'm trying... (2 Replies)
Discussion started by: gtangil
2 Replies

9. Shell Programming and Scripting

SSH sessions from bash script

Hello, I had to make an ssh connection to remote server from a bash shell script. I've summarized my research and I want to share it with you. I hope it will be useful to somebody or it will get improved. Bash has an option, which is called "input redirection", I think. It is something similar to... (3 Replies)
Discussion started by: tsurko
3 Replies

10. Programming

C programming sessions

Hey guys, i'm in trouble, i'm high school teacher, and a student ask me for help, he want's to know where he can study C language for his application exam. Somebody could help us? (1 Reply)
Discussion started by: eleia
1 Replies
Login or Register to Ask a Question