Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting / ~#root -i
  • RU
  • UA
  • EN
  • Create an online store
  • Documentation
  • Blog
    • Unix ОS
    • Php
    • MySQL
    • JavaScript
    • Package Managers
    • Docker
    • Seo
  • Auxiliary services
    • Short Links
    • Exchange views YouTube
  • Sign in
  • Create Account
  • Home
  • Unix OS
  • Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting

Configuration file (php.ini) when running Cron (cli) changing parameters (memory_limit) on hosting

If you encounter restrictions in the console when running a php script or with a restriction when setting a php task on cron, you will most likely look for the ability to change the settings of the php.ini file with your host. The probability that such settings will be in the hosting panel is very low.

Task:

Let's say you need to run a script that is in the path /var/www/script.php and it needs 1 GB of RAM to process some information. It is not possible to launch it from the browser due to long processing or you need to put the script in the scheduler.

cron (cli):

php /var/www/script.php

When running the script, we have:

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/script.php on line NUMBER_LINE

Solution:

If the hosting allows, then the cli or cron task can be run with its own configurations.

1. Let's create a php.ini file (for example, in the /var/www/ directory next to our script.php)

2. Let's add the parameters we need to it (in this case, 1 GB memory_limit)

cli php ini

3. Run from console or put on cron

php -c /var/www/php.ini -f /var/www/script.php

-c - key after which the path to php.ini with our parameters is set

-f - key after which the path to the script to be run is set

Tested on hosting: 100% supported on hosting ukraine.com.ua

28 September 22
76
0

Comments

Name
E-mail
Rating
Review

Other articles from the category

12 August 2022

Ubuntu Apache 2.4 Bad Request Size of a request header field exceeds server limit

Configuring Apache for high volume Cookies. Let's analyze the error "Bad Request. Your browser sent a request that this server could not understand. Size of a request header field exceeds server limit." and options to configure the server.

26 May 2022

Ubuntu black screen after driver installation on Nvidia 630M

Let's try to cure the black screen when booting Ubuntu after installing proprietary nvidia-340 driver on Nvidia 630M laptop.

06 January 2022

USB not working after Ubuntu 18.04 update on laptop

When USB 2.0-3.0 stopped working after updating Ubuntu on a laptop.

18 December 2021

Running Skype (skypeforlinux) in multiple Ubuntu windows

Ability to run Skype in multiple windows. Installed on Ubuntu skypeforlinux run in 2 windows.

23 March 2020

Disabling bluetooth speakers, dos attack on bluetooth in Linux

Let's consider one of the ways to dos-attack on bluetooth through the basic l2ping tools in linux. Let's analyze a simple python script.

30 December 2019

Store e-mail locally, Ubuntu sendmail stub for Php

Consider a script that saves e-mail to a file. Sendmail stub, setup in Ubuntu.

26 June 2019

Ubuntu 18.04 initramfs error

Let's analyze one of the reasons for the initramfs error when starting Linux Ubuntu 18.04. Let's try a system restore. fsck exited with status code 4.

31 March 2019

Npm : Depends node-gyp but won`t install Ubuntu 18.04

Unsatisfied links when installing npm, after installing node.js. Consider an alternative installation option.

Categories

  • Unix OS
  • Php
  • MySQL
  • JavaScript
  • Package Managers
  • Docker
  • Seo

Latest comments

Добрый день, Сергей. Я на более новых версиях блют...
root-i
23.02.23
Пробовал на transmart колонке. Ничего из перечисле...
Сергей
20.02.23
HenryMit, может быть
root-i
07.02.23
Неофрейдизм — это… Определение, принципы, представ...
HenryMit
07.02.23

I share information in which I needed help and spent a lot of time figuring it out. If the information helped at least one person, then this site was not created in vain.

Thank you for the continuation of the site:
Contacts

Telegram Viber Mail

Search for articles

  • Sign in
  • Create Account

Powered by chmod -R