ICT: Diary
D: 28 W: 05
| < | February 2015 | > | ||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
[ < ]
Tuesday, 24 February 2015 [ >
]
cli
While looking for:
while [[ $(pgrep -c -f "ssh " ) -le 20 ]]; do sleep 10; done; echo "There is a problem" # Do something special number of ssh processes > 20
— Command Line Magic (@climagic) February 23, 2015
this tweet I came across
What is the equivalent of /proc/cpuinfo on FreeBSD?
sysctl hw.model hw.machine hw.ncpu
More http://t.co/Y74YGZmTmr pic.twitter.com/YYvFaEJnJA
— nixCraft (@nixcraft) February 23, 2015
which also works for OpenBSD:
port:fred ~> for i in machine model ncpu
Finish the line --> do sysctl hw.$i
Finish the line --> done
hw.machine=amd64
hw.model=Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
hw.ncpu=4
But pgrep on OpenBSD does not have a -c count option so the OpenBSD version would be:
#!/bin/ksh
#
#set -x
while [[ $(pgrep -f "ssh" | wc -l) -le 8 ]]
do
sleep 2;
done
echo "We have more than 8 connections"
reset
For fixing broken terminals.
tee
Can be used to write a file in vi / vim when you don't have write permissions:
:w !sudo tee %
Benchmarks are Bad
benchmarks are bad: a reply on misc@ from Nick Holland.
DRY
Don't Repeat Yourself
$Id: dates.htm,v 1
$Id: diary,v 1.38 2025/01/01 22:43:54 fred Exp $