• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Cronjobs: User-defined php settings?

JensN

New Pleskian
Hi,

I have an issue getting user-defined php settings working for cronjob / planned task entries. In detail I want to increase the memory limit for a laravel 5 cronjob. For the customer the php settings the memory limit is already raised (to 512M), but the default limit is at a lower value (128M).

If I use the "Execute PHP script" option I can properly setup the command line parameters and PHP-Version, but it will always use the global default values (128M). For obvious reasons I dont want to increase the memory limit for the whole server.

If I use the "Execute command" option I can not run the php script at all because the php executables are not available within the chroot environment. (Right?) For obvious reasons I don't want to enable unprotected shell access for the whole server. (Enabling that Option for a single customer would already be better, but still a workaround)

If I use the "Query URL" option I have to build a workaround (see below) for executing CLI commands from a php script. Also I have the cronjob script publicly accessible which may be used for DOS in the worst case (or at least putting high load on the server). Also not a desirable solution.
PHP:
<?php
$_SERVER['argv'] = [ "artisan", "queue:work", "--queue=plugins,default", "--once" ];
include "../artisan";

Is there any better way to solve this? I'm really staggered that I couldn't find anything about this even after extensive search, since this should actually be a pretty common issue?

Thanks in advance
Best regards Jens N
 
Last edited:
Hello,

to increase php memory_limit , you can edit directly the php.ini configuration in Tools & Settings > PHP settings > php version you want to use to run your cronjob.
Then go in the tab php.ini and find the variable memory_limit
 
Up until recently I haven't had any clients with a need to run PHP scripts....
But now I have.

He's using the GIT extension and after it is finished he needs to run a PHP-script.

I already created a chroot environment for him and because his script didn't run properly I started investigating it.
By default it uses the OS-php that I prepared for him in chroot...
His script insisted on using PHP 7.1.2...
So I decided to add the Plesk PHP 7.1.2 to his environment too...

I think that's the best you can do for that client.
It will also give you the possibility to test things on an SSH-prompt in HIS environment...

It took me a month to refine the chroot environment. Of course not that many hours... But playing with it, you'll find that something doesn't work...

I think it runs fine now....
The (external) webmaster of our client wanted to move the website to a VPS so he could have root access. I convinced him to stay on our Plesk system and offered him the chroot environment.
 
Last edited:
Back
Top