exec('cd /home/admin/web/www.site.ru/public_html/css/&&sass --watch' )
&& sass you run. but: you run it not in the background, php runs in one thread, sass starts, php waits for it to stop working, to return the result, sass is started with --watch
, it is not going to leave the monitoring cycle, therefore php waits forever, the web server and browser bother it all, you get an error.
Try running cd /home/admin/web/www.site.ru/public_html/css/&&sass --watch main.scss:main.css --style compressed &
, as I recall, sass will then fly to the background, exec will return, and the script will continue to work on.
However, if you insert it into the script on the browser side, with each page refresh, you will have more and more sass exceptions launched (if it doesn’t keep track of its instances, of course - I don’t know if it’s monitoring or not). True, no one bothers you to run sass in a separate process simply via ssh, without inserting the call into the php script
Those. You do not have a problem with the exec function, but there is a problem with understanding the architectural bundle of php / web server / OS.
When you do ls
, you just run the command, get the output. When you run sass --watch
, you run it with an infinite loop.
PS &&
is a shell-specific construct. She will execute the command if the previous command did not return an error. Put spaces around &&
and other >
shell operators, except ;
This is just a good tone. Space should not be put in front ;
but should be put after, it is like a point in a sentence.