java用户在执行下面命令时不需要手动输入密码
sudo /usr/local/nginx/sbin/nginx -s reload
在/etc/sudoers文件中添加:
java ALL=(ALL) NOPASSWD: /usr/local/nginx/sbin/nginx
添加后的文件如下:
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
centos ALL=(ALL) ALL
java ALL=(ALL) NOPASSWD: /usr/local/nginx/sbin/nginx