This may seem to be a repeated question but it is not. I found some articles on it where start-stop-daemon doesn't create pid file. It is because the pidfile is not cerated.But in my case I have already created the pid file
I execute this command on my server to start nginx

1 Answer
1

The --make-pidfile option is required. The reason start-stop-daemon writes the "wrong pid" is that nginx forks. This is noted in the start-stop-daemon man page:

-m, --make-pidfile
Used when starting a program that does not create its own pid
file. This option will make start-stop-daemon create the file
referenced with --pidfile and place the pid into it just before
executing the process. Note, the file will not be removed when
stopping the program. NOTE: This feature may not work in all
cases. Most notably when the program being executed forks from
its main process. Because of this, it is usually only useful
when combined with the --background option.

(See the part re forking.)

You'll need to use a different solution, such as getting nginx to create its own pid file.