Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I cant find way to monitor single linux terminal command.

I want to monitor this command:

php index.php parse

The problem is this process works too short to get pid so I hope there is something like this:

singlecommandmonitor php index.php parse

Where singlecommandmonitor is software witch monitors ram, cpu ect. usage and php index.php parse is command I want to monitor. It should work similar to sudo, but instead of giving root permissions it should monitor resources.

I hope someone will understand what I need :)

Thank you for answers.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

You can use this simple tool: time:

\time -v php index.php parse

Please note that the backslash (or command time or full path like /usr/bin/time) avoids executing of a shell built-in. For example bash has its own time built-in which does not not collect information about the process memory.

By default this tool shows the information in a shortened form. With the -v option it shows it with more understandable descriptions:

$ \time -v sleep 2
    Command being timed: "sleep 2"
    User time (seconds): 0.00
    System time (seconds): 0.00
    Percent of CPU this job got: 0%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.00
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 2528
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 203
    Voluntary context switches: 2
    Involuntary context switches: 1
    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0
share|improve this answer
add comment

There is internal $! variable wicht contains pid. So this will do what I need:

php index.php parse & top -p $!
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.