Hello, I want to run php file on fedora terminal in background. However I am not able to run any of the file. When I execute the php file in normal way, I am getting the results, However when I try to run the same file in background on linux terminal it gets stopped with blank output. Please suggest me for the same.
Thank you,
how do you run it?
Hi, I am running the below command on fedora terminal:-
php test.php > test.txt &
Regards, Gaurav.
what does php -i run from the command line show ?
Hi,
Please find the attached file as its a very big reply, So have piped it to an file.
Just a possibility, if you are running something from cron/terminal in the background is php in the path?
Try using the full path
/usr/bin/php or whatever it is on your system.
I tried that option, however its not working.
are you running the command as a user who doesn't have permission to run the php binary
Or are you saying that:
php test.php > test.txt //works
php test.php > test.txt & //doesn't work
If neither can you explain how you run it when it does work.
I am running the below command as root user. You are right :- php test.php > test.txt //works
Thank you, Gaurav,
Any chance of seeing your script?
Hello,
Below is my php file as I am unable to upload it -
<?php echo "test";
?>
I just tried exactly the same thing from my terminal and it works fine.
Is the file test.txt getting created when you run the script?
Yes the txt file is getting created, however when I am using cat command to view the txt file I am not able to view any output and the txt file answers saying stopped. Please find the below error:- Error :- "[4]+ Stopped php test.php > op.txt"
that is very strange. Do you have selinux enabled?
I have disabled selinux on my machine.
What is it you are trying to achieve. Maybe there is another way of approaching it.
planetphp;10994778 wrote:What is it you are trying to achieve. Maybe there is another way of approaching it.
I agree with the above - there may be a workaround to what you're trying to achieve.
For example, if you can successfully fork PHP into the background and it's the output redirection that's causing the problem, you could always try redirecting STDOUT inside the PHP code as suggested here.
I can run the same php on our servers. However i cant run this on my local machines. None of the local machine gives proper output. Selinux is disabled. I still dont know where I am goin wrong.
Please help me out.