bash script to restart apache if apachectl passes -


i'm working on bash script rewrites vhost files , restarts apache pick changes. works fine want check status of apachectl before restarting apache in case vhost files have syntax errors.

i know how run apachectl -s command line, want script work like:

if(apachectl passes){     service httpd restart  } 

i guess parse output , 'syntax ok' there better way?

you can just:

if apachectl -s;   service httpd restart else   // action if config parsing failed fi 

apachectl result non 0 exit code, jumping else branch.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -