LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   [Request] Killing a specific command in Linux? (https://www.linuxquestions.org/questions/linux-software-2/%5Brequest%5D-killing-a-specific-command-in-linux-4175662224/)

finalturismo 10-08-2019 01:02 PM

[Request] Killing a specific command in Linux?
 
1 Attachment(s)
Ok so i have a question about killing a specific shred process in Linux

I need to kill for example a shred process of many , but i don't want to kill them all.

I need this for a udev removal script for my hard drive wiper i have been working on.

I need to kill the following command "shred -v -f -z /dev/sday"

but when i issue the command killall "shred -v -f -z /dev/sday"

i get the following no such file or directory?

i don't understand why something so basic wont work with a simple command?

any help on this one guys, free rep :)





note: i cant kill the process with PID as the numbers change.

fatmac 10-08-2019 01:08 PM

Did you run it as root(?).

finalturismo 10-08-2019 01:28 PM

Quote:

Originally Posted by fatmac (Post 6045058)
Did you run it as root(?).



yes i tried that

273 10-08-2019 01:31 PM

Power the device off!
You have already lost whatever was overwritten.
Heck,don't shred important data!

scasey 10-08-2019 01:42 PM

where is killall installed?
On my system:
Code:

# which killall
/usr/bin/killall

...If that error is because the script can't find killall. Is this a bash script? Have you set up a PATH therein? Are you running from cron?

From man killall...emphasis added.
Quote:

killall sends a signal to all processes running any of the specified commands.
So, as I read it, your command would kill all processes named shred. I see nothing in the man page that will implement filtering of the process name being killed.

How do you know which one you want to kill, if you don't want to kill them all?
Check out pkill, perhaps.

finalturismo 10-08-2019 01:44 PM

Quote:

Originally Posted by scasey (Post 6045071)
where is killall installed?
On my system:
Code:

# which killall
/usr/bin/killall

...If that error is because the script can't find killall. Is this a bash script? Have you set up a PATH therein? Are you running from cron?

From man killall...emphasis added.

So, as I read it, your command would kill all processes named shred.

i was meaning to use kill , oops, but i found the solution.



Code:

pkill  --full "shred -v -f -z /dev/sdc"

scasey 10-08-2019 01:47 PM

Quote:

Originally Posted by finalturismo (Post 6045072)
i was meaning to use kill , oops, but i found the solution.
Code:

pkill  --full "shred -v -f -z /dev/sdc"

You were posting as I was editing ;)


All times are GMT -5. The time now is 12:26 AM.