coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Sunday May 27, 2012


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 22 guests online

Newest Member

beyondimagem

Hit Counter
9133536 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:595500
Members:16437





Category Search coolcommands.com
Select Category:


coolcommand

awk - oneliner to kill all current user specified processes if different from current time
Description

This is a oneliner which greps for a process, ensures it is running by the person who runs this oneliner and then makes sure it is not running at the current time. If not, it does a kill on the process.

# ps -ef | grep "your_process" | grep `whoami` | grep -v grep | awk 'BEGIN {"date" | getline date ; split(date,d," "); t = d[4]} substr(t,1,7) != substr($5,1,7) {system ("kill " $2 )}'

If you want to get all old processes except your current one, try:

# ps -ef | grep `whoami` | grep -v grep | awk 'BEGIN {"date" | getline date ; split(date,d," "); t = d[4]} substr(t,1,7) != substr($5,1,7) {system ("kill " $2 )}'
Example

ps -ef | grep your_process | grep `whoami` | grep -v grep | awk 'BEGIN { {"date" | getline date ; split(date,d," "); t = d[4]} substr(t,1,7) != substr($5,1,7) {system ("kill " $2 )}'

Return to search results

Random coolcommands

coolcommand: unison - a file-synchronization tool for Unix and Windows
Example: unison dir1 dir2
[show me the details]
coolcommand: unmirrorvg - how to unmirror a volume group in IBM AIX
Example: unmirrorvg workvg hdisk7
[show me the details]
coolcommand: how to create a JFS2 filesystem with internal snapshots in AIX v5.3+
Example: crfs -v jfs2 "-dhomeslv" "-m/homes" "-Ayes" "-prw" "-a" "agblksize=4096" "-a" "logname=INLINE" "-a" "isnapshot=yes"
[show me the details]
coolcommand: zcat - decompress a tar file
Example: zcat file.tar.Z | tar -xvf -
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1152
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris49379
Category AIX46267
Category General UNIX43933
solaris22927
aix22116

Terms of Use
Privacy
Contact


 
coolcommands.com © 2012. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum