Operating System - Linux
1752588 Members
4792 Online
108788 Solutions
New Discussion юеВ

Logging out a user account within a script

 
Andrew Kaplan
Super Advisor

Logging out a user account within a script

Hi there --

I am writing a shell script that will do a snapshot of a local hard drive, but there is a need for all users to be logged off when the script is run. This is due to the user accounts being NIS, and the home directories in question are NFS mounts which are supposed to be unmounted prior to the snapshot being made.

What would the correct syntax be in order to accomplish this? One idea that I had was the following:

# su -
# logout

If this works, how could I go about in checking for all logged in users, and repeating the above process? If this is not the correct method, what commands could I use to accomplish this task? Thanks.
A Journey In The Quest Of Knowledge
4 REPLIES 4
Steven Schweda
Honored Contributor

Re: Logging out a user account within a script

> If this works, [...]

No fear.
# su -
This starts a new process as .
# logout
This stops the process you just started. I
assume that you wish to stop existing user
processes, not new ones which you create.

How many systems are there?
On which system is the file system local?
On which system are the users logged in?
Andrew Kaplan
Super Advisor

Re: Logging out a user account within a script

Hi there --

Thanks for your reply. The answers to your questions, in the order that you proposed, are the following:

There are two systems involved in this scenario: The workstation, NIS client, and the server, NIS master, with NFS mounts exported to the workstation.

The filesystems that need to be unmounted are local to the NIS Master.

The users are logged into the workstation which is the NIS client.

If you have any other questions, please let me know, and thanks for the help.
A Journey In The Quest Of Knowledge
Sameer Kelkar
Advisor

Re: Logging out a user account within a script

Hi

Pls. see attached link. It may help you.It is having script which will logout all users.


http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1237011532645+28353475&threadId=926394

Viktor Balogh
Honored Contributor

Re: Logging out a user account within a script

just a small comment: AFAIK logout exists only in csh, though in the other shells you could have an alias for this ;)
****
Unix operates with beer.