Shelling scripting is a necessary skill
March 23rd, 2010
Yesterday a 20 line shell script caught a race condition in one of software I work on. Our best engineers looked at the problem, a vendor case was filed, and there was thoughts of automatically restarted the application to fix the issue at hand.
In the end, a 20 line shell script to strace for file operations continuously provided the needed visibility into the issue at hand.
Update: The shell script.
The shell script itself, though trivial, is owned by the company I work for, but the basic concept was as follows:
#!/bin/bash
# loop forever
while sleep 60
do
pid=$(ps -ef | grep application | egrep -v grep | awk ‘{print $2}’)
if [[ -n $pid ]]
then
outfile=strace-application-$(date +%Y%M%d-%H:%M:%S).out.gz
strace -tt -f -e trace=file -p $pid 2>&1 | gzip -c > $outfile
fi
done


March 23rd, 2010 at 5:16 pm
Snippet of the script?
March 23rd, 2010 at 5:52 pm
There you go…
March 24th, 2010 at 12:12 pm
What is the purpose of the “while sleep 60″ line?
March 24th, 2010 at 12:53 pm
Just so if the strace fails, the script does not go berserk. A “safety” mechanism of sorts.
April 6th, 2010 at 7:33 pm
Прив…
Спасибо…
May 9th, 2010 at 12:37 pm
Феоктист…
2106 тюнинг…
May 28th, 2010 at 8:37 am
СПС.…
Я тут…
June 5th, 2010 at 7:33 pm
http://rel” rel=”nofollow”> Спасибо,…
Хотя новость уже читал…