I would like to execute a php-script in the background, because it uses about 2 minutes execution time.
I am working with Cake 3.7.
I have the following script - just for testing: (It just writes a little file with name and time)<?php
$xfileName = date("Y-m-d H-i-s") . " Datenübername Dorothee";
$xfile = fopen("xfiles/" . $xfileName, "w+");
fwrite ($xfile, $xfileName);
In my controller I have the execution call like this:
shell_exec (‘php -f shelltest.php’);
The script is running nicely, but the view waits until it is finished.
I would like the script running in the background.
I tried like this:
shell_exec (‘php -f shelltest.php > /dev/null &’);
The script does not run at all.
I tried with exec instead of shell-exec. I didn’t help.
Do you have an idea, what I could do?
Thank you very much for your help.