- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to retrieve ksh started x hours ago and ki...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 05:03 AM
тАО02-23-2011 05:03 AM
I'd like to find the PID of all process link to a ksh script started 4 hours ago and kill them. Is it possible using a combination of ps, kill, awk commands?
Bests Regards
Den
Solved! Go to Solution.
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 05:07 AM
тАО02-23-2011 05:07 AM
Re: How to retrieve ksh started x hours ago and kill it.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 05:27 AM
тАО02-23-2011 05:27 AM
Re: How to retrieve ksh started x hours ago and kill it.
I'd use the XPG4 (UNIX95) options of 'ps' to match the *name* of the process exactly and return the elapsed time of the process in the format "DD-HH:MM:SS" which you can then easily dissect.
For example:
# UNIX95= ps -C swapper -opid=-oetime= -ocomm=
0 6-23:52:24 swapper
...would be PID-0 for the 'swapper' having run for 6-days, 23-hours, 52-mintes and 24 seconds.
Note the whitespace after the 'UNIX95='. There is no semicolon before the 'ps' command. This keeps the NIX95 behavior set only for the command duration. To do otherwise may lead to nasty surprises.
The "=' sign after the 'ps' options suppresses the header for that option. This simplifies filtering of the output.
The '-C
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 05:54 AM
тАО02-23-2011 05:54 AM
Re: How to retrieve ksh started x hours ago and kill it.
A space is missing above and Leo may want to look for ksh:
# UNIX95=EXTENDED_PS ps -C ksh -opid= -oetime= -ocomm=
6101 00:26 ksh
3436 22:21 -ksh
You probably don't want to kill that "-ksh" login shell.
- Tags:
- EXTENDED_PS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 06:00 AM
тАО02-23-2011 06:00 AM
Re: How to retrieve ksh started x hours ago and kill it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2011 04:30 PM
тАО02-23-2011 04:30 PM
Re: How to retrieve ksh started x hours ago and kill it.
$export UNIX95=1
$while true; do ps ├в efHx > /tmp/ps.`date -u +%d%h%m%H%M` ; sleep 60 ; done
you will have to kill the processes manually
Regds,
INH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2011 08:24 AM
тАО02-28-2011 08:24 AM
Re: How to retrieve ksh started x hours ago and kill it.
Yes i know the owner: oracle and I know all scripts potentially in the target of my command. All my scripts are starting by xxx_
Example: xxx_check_instance.ksh
I'm looking for something like:
ps -"option" time-10 -name xxx_*
after that I'll have the PID and I'll be able to kill them....
Bests regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2011 09:23 AM
тАО02-28-2011 09:23 AM
Solution> I'm looking for something like:
ps -"option" time-10 -name xxx_*
after that I'll have the PID and I'll be able to kill them....
And that's where my original post is trying to point you. You do:
# UNIX95= ps -C myprocess -opid= -oetime= -ocomm=
...where 'myprocess' is the basename of that which you seek. The PID and elapsed time are returned like this:
1234 1-2:33:44 myprocess
In this example, the PID is 1234 and the elapsed time is one-day, 2-hours, 33-minutes and 44 seconds. It's not difficult to parse-out these values and decide if the process(es) are older than four hours. With the PID, you then kill as necessary.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2011 12:34 PM
тАО02-28-2011 12:34 PM