I have a php file and it takes 11 minutes to upload and process excel.
I want to do this in the background with shell_exec, but I get an error like this.
File "/tmp/phpG4jVlp" does not exist.
The command I am using is as follows.
/www/server/php/74/bin/php -f /background_processes/inventory_excel_upload.php 'eyJmaWxlIjp7Im5hbWUiOiJJbnZlbnRvcnkgMTkuMDcuMjAyMiAxMF8yM181OC54bHN4IiwidHlwZSI6ImFwcGxpY2F0aW9uXC92bmQub3BlbnhtbGZvcm1hdHMtb2ZmaWNlZG9jdW1lbnQuc3ByZWFkc2hlZXRtbC5zaGVldCIsInRtcF9uYW1lIjoiXC90bXBcL3BocEc0alZscCIsImVycm9yIjowLCJzaXplIjo0MjI4MDJ9fQ=='
output of the parameter:
{
"file":{
"name":"Inventory 19.07.2022 10_23_58.xlsx",
"type":"application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"tmp_name":"\/tmp\/phpG4jVlp ",
"error":0,"size":422802
}
}
I have given the file path as a parameter. Is there any other way?
CodePudding user response:
If you have your own Ubuntu server running you may encounter the maximal file size upload limit in php scripts which is set to 2Mb as default. In order to change that we first have a look what the size actually is. In /var/www (standard www directory) create a file called info.php with the following content:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Then browse to this file via localhost/info.php (replace localhost with the servername if necessary) and look for the line upload_max_filesize 2M
which will show you the actual maximum file size. In order to change that open a ssh connection to your server and edit the file /etc/php5/apache2/php.ini with
sudo nano /etc/php5/apache2/php.ini
search for “upload_max_filesize” with Ctrl-W and change “2M” to “20M”. Save the file with Ctrl-O and exit with Ctrl-X. Restart the apache server with
sudo /etc/init.d/apache2 restart
CodePudding user response:
actually here is the problem.
to the end of the command
/dev/null 2>&1 &
If I add it, my codes work fine, but the process does not run in the background.
If I don't add it, I get an error.