LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-08-2019, 01:02 PM   #1
finalturismo
Member
 
Registered: May 2019
Posts: 41

Rep: Reputation: Disabled
[Request] Killing a specific command in Linux?


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.
Attached Thumbnails
Click image for larger version

Name:	screen_shoots_shreds.jpg
Views:	13
Size:	260.4 KB
ID:	31481  

Last edited by finalturismo; 10-08-2019 at 01:04 PM.
 
Old 10-08-2019, 01:08 PM   #2
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Posts: 3,119

Rep: Reputation: Disabled
Did you run it as root(?).
 
Old 10-08-2019, 01:28 PM   #3
finalturismo
Member
 
Registered: May 2019
Posts: 41

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
Did you run it as root(?).


yes i tried that
 
Old 10-08-2019, 01:31 PM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,364

Rep: Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258Reputation: 2258
Power the device off!
You have already lost whatever was overwritten.
Heck,don't shred important data!
 
Old 10-08-2019, 01:42 PM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,778

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
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.

Last edited by scasey; 10-08-2019 at 01:45 PM.
 
Old 10-08-2019, 01:44 PM   #6
finalturismo
Member
 
Registered: May 2019
Posts: 41

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
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"
 
Old 10-08-2019, 01:47 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,778

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Quote:
Originally Posted by finalturismo View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dhclient command to request a specific ip address ubuntuv Linux - Networking 4 03-12-2012 03:38 PM
Killing a Specific Process the_satsuma_man Programming 4 03-11-2009 09:42 PM
Killing a specific instance of a program created by a script derriva Programming 2 12-27-2006 04:42 AM
How to make a specific command(s) work for specific users or group only naren_0101bits Linux - General 3 08-28-2005 05:22 PM
How to make a specific command(s) work in a specific shell only naren_0101bits Linux - Newbie 3 08-28-2005 01:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration