Agnello George wrote:
i am trying to write a script on my *test machine *to check if the process are running , and if they are not need to start them any idea why this is not working ??
Can you post the errors?
1. ps doesn't require a '-' before parameters. You get a warning message if you do add it. Remove it.
2. $9 in awk gives nothing. Try $8 instead.3. The if condition starts the service if the process is running. Huh?!? Shouldn't it be the other way around? 4. None of my business, but why do you want to start every service on the system?
Below is a modified version of the script. Works on my system, Fedora Release 8.
#!/bin/sh
SERVICES=`ls -l /etc/init.d/ |awk '{print $8 }'`
for i in $SERVICES
do
if [ $(ps aux|grep -v grep |grep $i |wc -l) != 0 ];
then
echo RUNNING - $i
else
echo STOPPED - $i
fi
done
--
Regards,
विवेक ज. पाटणकर (Vivek J. Patankar)
Registered Linux User #374218
Fedora release 8 (Werewolf)
Linux 2.6.23.15-137.fc8 x86_64
signature.asc
Description: OpenPGP digital signature
-- http://mm.glug-bom.org/mailman/listinfo/linuxers

