Log off remotely
Solution 1
First you'll need to connect to the machine(s) where you have left processes running. Use SSH.
You can kill a process by sending a signal to it. In your case, the right signal for the job is SIGHUP. This signal is sent automatically when a terminal disappears (etymologically, it was sent when the modem hung up).
If you want to close all the sessions on that machine, send SIGHUP to all the processes. You can do that with
kill -HUP -1
-1
means “all processes”. You can't kill other users' processes, so this will only kill your processes.
If you only want to kill some processes, you can run the following command to list all the processes running on your account:
ps -u $(id -u) -ww
Once you've decided which processes to kill, carefully copy the values from the PID
column. E.g. to kill PID 123 and 125:
kill -HUP 123 125
If a process doesn't react to SIGHUP, send SIGKILL. SIGHUP asks nicely, whereas SIGKILL doesn't give the process a chance.
kill -KILL 123 125
Solution 2
You can use the command who -u
that gives the list of users logged in, along with the PIDs of the shell sessions.
root@server:/# who -u
root - pts/0 2017-08-08 15:52 00:08 21934 (192.168.5.33)
root - pts/1 2017-08-08 16:07 . 31669 (192.168.5.33)
Then kill the shell sessions accordingly (in your case, sessions belonging to your user):
root@server:/# kill 21934 31669
Note that killing the shell will have the consequence of killing the parent ssh session.
Related videos on Youtube
R.Bichi
Updated on September 18, 2022Comments
-
R.Bichi almost 2 years
I have worked yesterday with my collegue on his computer and I logged in to my cluster account (with ssh) but I left the session open and I am home now.
I don´t know if he closed the session after me.
I need to log off (exit) all open sessions of my cluster from my computer.How can I log off all open sessions?
Note: changing the password can help but I can not change the password
-
daisy almost 7 yearsAnd you can't login again and kill the old sessions?
-
R.Bichi almost 7 yearsI can log in from my computer for sure but how should I kill other open sessions in other computers ? what is the command please?
-
-
JdeBP almost 7 yearsFor best results, send the hangup signal to the session leader process, not the termination signal which most shells will simply ignore.