Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uptime and ps aux|head -5 1

Status
Not open for further replies.

loloman

Technical User
Oct 30, 2002
16
0
0
FR
I want to do a shell who scan my server with uptime
and when uptime load average > 4, i want to write
the result of ps aux|head -5 in a file
for ex :
uptime
11:36 up 4 days, 12:26, 51 users, load average: 1.40, 1.03, 0.84

if uptime | awk -F" " '{print $10}' > 4 then
ps aux|head -5 > log
 
Try something like this :
[tt]
uptime | awk '{ sub(/,$/,"",$(NF-2));if ($(NF-2)>4.) exit 1 }' || ps aux|head -5 > log
[/tt]

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top