On Saturday 15 Mar 2008 16:47:40 Agnello George wrote:
#!/bin/sh -x
Are you sure you want sh and not bash? sh is a good standard compliant practise, but if you're not going for portability, I'd highly recommend bash. Keep in mind, that on Debian/Ubuntu, sh is now linked to dash instead of bash.
SERVICES= `ls -la /etc/init.d/ |awk '{print $9 }' |sed -e 's/[^[:alnum:]]//g'`
awk and sed together is... hmm, a waste of resources. Two extra processes for no reason. Awk does everything sed can and sed does everything grep can, so stuff like `grep | sed' or `sed | awk' and vice versa is bad.
if [ $(ps -aux|grep -v grep |grep $i |wc -l) != 0 ];
This one is `ouch'. You need this:
http://wooledge.org:8000/ProcessManagement