Why do we use /etc/init.d/httpd start
in the below program? Why can't we use service httpd start
? For me it's showing as unrecognized service. (I have installed httpd already.)
#!/bin/bash
if (( $(ps -ef | grep httpd | wc -l) > 1 ))
then
echo "httpd is running!!!"
else
/etc/init.d/httpd start
fi
:-) vishal I don't mean to frustrate you. However, it's difficult to answer your question without a lot of assumptions.
/etc/init.d/httpd start
ps -ef
test assumes the process name to be httpd and sometimes it's notservice httpd start
There may also be good reasons for not using service httpd start
in this script because it may have side effects. For example,
service
may not have httpd registered as a service service
you may end up relaunching other dependent services which you may not want to doservice
may bury the errors during start up and you may want to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.