Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ sudo nginx -t
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- [root@d ~]# /usr/local/nginx/sbin/nginx -t;echo $?
- nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
- nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
- 0
- [root@d ~]# echo whatever > /usr/local/nginx/nonsense.conf
- [root@d ~]# /usr/local/nginx/sbin/nginx -t -c nonsense.conf;echo $?
- nginx: [emerg] unexpected end of file, expecting ";" or "}" in /usr/local/nginx/nonsense.conf:2
- nginx: configuration file /usr/local/nginx/nonsense.conf test failed
- 1
- #!/bin/bash
- /usr/local/nginx/sbin/nginx -t 2>/dev/null > /dev/null
- if [[ $? == 0 ]]; then
- echo "success"
- # do things on success
- else
- echo "fail"
- # do whatever on fail
- fi
Add Comment
Please, Sign In to add comment