![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 09:25 AM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 04:19 AM |
| Bash under AIX 5.3 | taupin | AIX | 4 | 03-21-2008 03:03 AM |
| From bash to csh and zsh | lev_lafayette | Shell Programming and Scripting | 10 | 09-10-2007 08:48 PM |
| Bash it! Bash it! | SoulForge | Shell Programming and Scripting | 5 | 11-22-2002 10:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash: how to do it?
Hi
My problem is that i need to measure given command statistics (time, mem, etc) with shell script My script must basically do two things: 1. Measure overall command statistics (it is total time, maximum memory use during runtime, etc) 2. Measure command statistics in given periods of time during it's run (once a x seconds) Then i have few questions: 1. what is the best method for checking command statistics during runtime (for example ps returns process time in seconds, but i need better resolution (are jeffes realible)) 2. How to make gathering data during run and after that possible. my idea is that i test given command overall statistics with time command, and use some other command to test statistics during its runtime, but... how to detect that command finished? let's say that i use time for overall statistics, i have to do something like that [time given_command...] & part_of_script_testing_given_command_during_runtime how to get pid of [time given_command...] in the main script? and if you know some examples of such script, can you give some links? if you know please help thx Charles |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
You can get the pid of "time command" by grepping for "command" name, for example : "time cat" ; "pgrep cat" - this will return the PID of cat. Disadvantage : if you have multiple cat command, "pgrep" will return all of them.
Code:
for i in `seq 1 100`; do time ps -ef >> logfile.log; sleep 2; done Also, if your distro has it, take a look at the options of "usr/bin/time" - this is kinda different than the "time" command. For the other things that you're asking, can you please provide some examples ? |
|
#3
|
|||
|
|||
|
hm... there is problem about /usr/bin/time. It doesn't return maximum resident set size, which i need too (it always return 0 instead). Is there a way to get maximum resident set size of a process that has finished?
also this: Code:
for i in `seq 1 100`; do time ps -ef >> logfile.log; sleep 2; done Code:
time -o "logfile.txt" -f "parameters i want" my_given_command & childpid=$! for i in 'seq 1 100' do; gether_and_write_childpid_statistics; sleep 1; done; write_statistics_from_time_command 1. i would like to know if childpid has finished and break the loop then (better if i could do it in sleep command, but i dont know if its possible). i don't want to gather data from finished process 2. i would like to have reliable command for monitoring childpid (ps only returns cpu time in seconds, i don't know if i can monitor it better) 3. and the problem with time that i write about at the beginning, how to obey it? Thx Last edited by sopel39; 11-01-2007 at 08:53 AM. Reason: code tags |
|
#4
|
|||
|
|||
|
Also is there a command that wait's for child for specific amount of time and if child wont finish it return error after that period?
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|