Sunday, 15 March 2015

linux - Get the load, cpu usage and time of executing a bash script -



linux - Get the load, cpu usage and time of executing a bash script -

i have bash script plan run every 5 or 15 mins using crontab based on load puts on server.

i can find time of running script, load, memory usage , cpu usage not sure how find.

can help me?

also suggestions of rough benchmark help me decide if script puts much load , should run every 15 mins , not 5 mins.

thanks in advance!

you can utilize "top -b", top gives cpu usage, memory usage etc, insert these lines in script, process in background , terminate process testing overs.

ssh server_name "nohup top -b -d 0.5 >> file_name &"

\top process run in background because of &, -d 0.5 give cpu status @ every 0.5 secs, redirect output in file_name latter analysis.

for killing process after test, insert next in script,

ssh server_name "kill \`ps -elf | grep 'top -b' | grep -v grep | sed 's/ */ /g' |cut -d ' ' -f4\`"

your main testing script should between top command , command killing top.

i presumed running script client side, if not ignore "ssh server_name".

if running client side, because of "ssh", asked password, avoiding follow these 3 simple steps

this solve issue.

linux bash load crontab resource-utilization

No comments:

Post a Comment