Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-29-2004, 10:14 PM   #1
LQ Newbie
Registered: Sep 2004
Posts: 1

Rep: Reputation: 0
Question Need to kill process 48 hours old

I need to get a script or learn how to make one that will tell me:

1. what emacs processes are running
2. kill the processes that are over 48 hours old.

in addition a little cron help would be nice. I want to have this process email me with what it killed when its done.


Captn Z
Old 09-30-2004, 12:51 AM   #2
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Try this at the command line:

ps -eo "%p %t %c" | grep emacs | grep "-" | grep -v " 1-"
If that successfully displays emacs sessions that have been running over two days, you should be able to do this:

for x in `ps -eo "%p %t %c" | grep emacs | grep "-" | grep -v " 1-" | cut -c 1-5`; do
  echo Killing process: `ps -p $x -o "%p %a"`
  kill -9 $x
Old 09-30-2004, 12:54 AM   #3
Registered: Aug 2004
Location: Israel
Distribution: Ubuntu 10.10
Posts: 271

Rep: Reputation: 34
As root do
You get a list of processes running on your machine.To kill one hit K,it asks you about PID(process' number).Enter a number,hit enter,then 9,enter.Process killed.Hit Q to leave.
Old 09-30-2004, 02:06 AM   #4
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Hi Cro,

I ran that with mine and get an output of:

132 9-03:45:15 emacs.

Can you explain what "9-03:45:15" means? Looks like 3 hours, 45 mins, and 15 seconds but what is the 9-? Thanks...

Old 09-30-2004, 02:38 AM   #5
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Nine days (plus three hours, forty-five minutes and 15 seconds)

(Gee - didn't know ps could do all that - you just made my day - thanks :-)


Old 09-30-2004, 03:07 AM   #6
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Yeah, that was what I thought it was, but my server has a process with 42483-02:00:00 listed, and I haven't even had the server running that long, so I just had to check the ps source code to make sure... and it seems that's what it should be. My 42000 day process is some kind of anomaly


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
Process won't kill mrsolo Linux - Software 5 08-03-2007 12:45 PM
cannot kill process (kill -9 does not work) mazer13a Linux - General 1 05-27-2005 02:32 PM
can't kill the process ust Linux - Software 2 12-16-2004 11:53 PM
how to kill a process in C++? mimithebrain Programming 9 06-17-2004 05:20 PM
How to kill a certain process? AMDPwred Linux - General 3 10-01-2002 01:40 PM

All times are GMT -5. The time now is 04:40 PM.

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