Operating System - HP-UX
1832566 Members
5605 Online
110043 Solutions
New Discussion

Re: how to kill the user process loging on now?

 
常有慈悲心
Regular Advisor

how to kill the user process loging on now?

Hi,
I want to do a job every day, and at first i must kill all the user process and logout all the user. how can i accomplish this using the shell script?
5 REPLIES 5
Sanjay Kumar Suri
Honored Contributor

Re: how to kill the user process loging on now?

You can user fuser commane to achieve this

#fuser -ku /file_system

You must be super user.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Bharat Katkar
Honored Contributor

Re: how to kill the user process loging on now?

You can use following command in your script to read the information:
#who "gives you all users in the system. Get the tty no. of every users."
#ps -t "This will list all processes related to that user with their PID's."
#kill -9 "kill the particular process."

If you kill the sh process of the user, he gets automatically logged out.

Hope this is sufficient
You need to know a lot to actually know how little you know
Steve Steel
Honored Contributor

Re: how to kill the user process loging on now?

Hi

What type of job is it.

If you are running a database application just killing things is a bad idea.

Also things like lp which is maybe seen as a user does not like being killed.

You would be safer going to runlevel 1 or 2
and then running.

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Sanjay Kumar Suri
Honored Contributor

Re: how to kill the user process loging on now?

You can also introduce a start script in the directory /sbin/rc2.d directory which will get executed whenever run level changed from 1 to 2 and so on.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
KapilRaj
Honored Contributor

Re: how to kill the user process loging on now?

who -u |awk '{print "kill -9",$7}' |ksh

Modify it for u'r use

Kaps
Nothing is impossible