Golang exec: stat: no such file or directory after file has been moved there

Viewed 3415

I have a script that I am using for deployment using the "os/exec" package. One of the commands that I use is as follows:

cpInit = exec.Command("cp", "initScripts/nginx", "/etc/init.d/nginx")

and another:

startNginx = exec.Command("/etc/init.d/nginx", "start")

Initially I ran the first command with err := cpInit.Run(), but later when I run the second command I get the error:

exec: "/etc/init.d/nginx": stat /etc/init.d/nginx: no such file or directory

But when the program exits /etc/init.d/nginx is there, so I thought maybe the first command didn't finished (even though Run() waits until the command returns). I changed Run() to Start() and Wait() only to get the same results. Can anyone tell me why the second command can't find that file?

1 Answers
Related