Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm using rsync to relay nginx configuration from server A to server B:

0,10 * * * * rsync -avz -O --delete /etc/nginx/sites-available -e "ssh -i /home/ubuntu/key.pem" [email protected]:/etc/nginx

Once that is done (every 10 minutes) I need to reload the remote server's configuration. How can I execute service nginx reload on the remote server as root?

share|improve this question

If you start your nginx server as ubuntu (ssh -i /home/ubuntu/key.pem" [email protected]:/etc/nginx), you don't need to reload as root.

You can send the reload signal to the current nginx process:

ssh -i /home/ubuntu/key.pem" [email protected]:/etc/nginx -s reload
share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.