KILLING Mac OS
- Discovering, restarting, and killing these processes are essential lessons for mac and unix users. Susan tweeted me the following yesterday: After I completed one of your mac tech-recipes tutorials yesterday, I was unable to logout from my terminal session in OS X. The message that “there are stopped jobs” appeared and prevented me from.
- Active@ KillDisk for Mac is an easy-to use & compact freeware utility that allows to sanitize attached media storage with the 24 international data sanitizing standards. It permanently erases all data on Hard Disks, Solid State Drives, Memory Cards & USB drives, SCSI storage & RAID disk arrays.
Click here to return to the 'Kill process by name instead of PID' hint |
To kill program Mac OS X terminal on Leopard / Snow leopard / Lion do the following commands: Get the ID of the program ps -A grep name of program you want to close Kill the program. This will give you the number of the processes found (if any). Now just close them with this command. You can kill or stop a process from the Terminal using the command launchctl, but killing alone will not suffice, because Photos will just restart the process again. You would have to disable photoanalysisd from ever running again.
Killing Mac Os Sierra
pkill sshwill attempt to kill every process with the text string 'ssh' in it, including not only ssh-sessions, but also ssh daemons and your ssh-agent. Which is why this script should never be run as superuser (I could find a lot worse examples than with ssh above).... Personally, i prefer double checking processes before i kill them. Look them up with ps and kill them with kill, slightly inconvenient, but safe
yeah, gotta agree with kal, this is an extremely bad practice. one needs to know the potential effect of blindly running this kind of operation.
Why not use the '-w' flag for grep to match on a whole word?
ditto
I found this command immediately after submitting this script. doh.
live and learn - we all do
**this is not a flame it's meant to be constructive critisim**
at the least you should not be matching things like ssh-agent if you choose ssh with this script. that is just wrong. sorry! because if you do that you can trigger all sorts of problems killing processes that you did not intend to kill...
this script is a duplication of functionality and while it is intersting and duplication of functionality is kinda what open source is all about this script is just dangerous!!!!
granted that the danger is minmal, esp if the script is not run as the superuser... there is little you can do, but throwing around kill's arbitrarily will screw things up!
for example i have both inetd and xinetd running here for some reason??? anyone know why??? and if i ran your script with 'inetd' it would kill inetd && xinetd that's just wrong... especially when there are better tools on the system that will do the job properly 'killall' ????
i'm not trying to be rude at all but... at least do exact process name matching.
Mac Os Catalina
a modification for pidof to kill....
the default is to send a sighup but you can kill too
ie ./kill name sig
place this script somewhere and chmod it 755
it's the perl version so the matching is better!
the base for this code came from someone who submitted a perl version as a comment to my bash&tr&awk pidof script, i forget his name but just want to make people know it's not entirely my own.. but heavily modified.
<code>
#!/usr/bin/perl
$search=$ARGV[0];
if ($ARGV[1]) {$sig=$ARGV[1]; } else { $sig=1; }
@procs = `ps -cxa`;
for $proc (@procs ) {
if( $proc =~ /s+(d+)s+S+s+S+s+S+s+(S+)/ ) {
$pid = $1;
$name = $2;
if( $name =~ /^$search$/ ) {
kill $sig,$pid;
print '$pid ';
}
}
}
print 'n';
</code>