When I use php to
exec('sort /var/www/website/file_in.txt -o /var/www/website/file_out.txt');
the file that is output from the sort command is trunacted
input filesize= 2,442,541
output filesize= 1,146,881
I also noticed, when using php function filesize(file_in.txt), the returned value = 1,146,881, not the correct size as shown in a terminal session. I did call clearstatcache() prior to calling filesize().
Interestingly, filesize reports the size of the file_in as the same value that file_out is truncated to.
I am running a Linux _x86_64 64bit PHP version, so I thought that eliminates the 32bit filesize limitation issue for files gt 2MB.
When I run the sort command in a terminal session as user www-data, the output file is the same size as the input file, no truncation.
I tried writing a shell script to call from exec, hoping it would bypass a possible php buffer limit, but it has the same truncated output file.
I have TOP running in a separate terminal to watch CPU and MEMORY usage, but since the coammdn when run in a terminal does not truncate the output, this appears to be a PHP issue.
Is there any kind of obscure configuration .ini setting that I should check to solve this issue?
Thanks
Additional Info: I realized the output file is not being truncated, but rather, the input file is not being fully read in until EOF.