0

I can use "nginx -s reload" command to restart nginx on the shell. But, when I use os.system("nginx -s reload") command, It appears error.

/usr/local/bin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory For this error. I already install pcre. Is there some magic problems.

0

2 Answers 2

4

For running such commands in python scripts it's better to use subprocess library.

try this code instead of yours:

import subprocess
subprocess.call('whatever command you want to run it in terminal', shell=True)

Be lucky

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your suggestion.
0

hello I recommend that you first send this validation before sending the reset so you avoid headaches

reinicioNGINX = subprocess.getoutput(['nginx -t'])

if 'nginx: the configuration file /etc/nginx/nginx.conf syntax is ok' in reinicioNGINX:

_command_restart

else:

_command_avoid_restart

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.