ps -axwwo command | grep lame | grep -v grep > ~/Desktop/lame_command.txt
This example would save a file to your desktop containing the commands that initiated running processes which included the term lame, for example.
|
|
|
If you know the name of a running command line process, but don't know the precise command line with which it was invoked, you can run a command such as this one to return the complete command:
This example would save a file to your desktop containing the commands that initiated running processes which included the term lame, for example.
•
[5,410 views]
Hint Options
Just a related trick
The following line does the same faster and easier:
Just a related trick
Thanks!
Just a related trick
Try using the script command. Just type script on the command line. It will create a file called typescript that will capture everything. When you are finished, just press CONTROL-D to end.
Just a related trick
That appears to capture commands entered into the terminal window. What I'm looking for is a way to capture all commands executed on the machine between start time and end time I specify.
Just a related trick
ps -axwwo command | grep [l]ame > ~/Desktop/lame_command.txt The brackets in the pattern '[l]ame' are not controlled by the shell, instead they're passed to grep which expects a list of characters between the brackets any of which will match (in this case just 'l'). It still achieves the same effect because as a pattern '[l]ame' will match the string 'lame' but not the string '[l]ame'. That's probably more confusing than helpful - sorry! It is a neat trick.
Capture commands that launched processes
Well, if I'm not wrong, there's no direct way to do this using "standard" shell script commands. As 'ps' shows the start time in 3 different formats depending on how distant it is from current time, you can create 3 functions to load the time and convert it, for example, to seconds from the epoch. Once you have the time in seconds it's very easy to test which is between limits and print it.
Correction to my previous comment
Sorry, I'm asleep. If you want to look for concrete processes on time, you can use 'lstart' instead of 'start' to get a "normalized" time string, much easier to compare with others. So: |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.26 seconds |
|