System Information Ubuntu Version: 22.04 Kernel Version: 5.15.0-57-generic x86_64 PHP Version: 8.0 When setting cron, it is not normally applied. After 10 minutes, the following message is displayed. 'Last background job execution ran 10 minutes ago. Something seems wrong.' Here's how I tried to fix this problem. • Modify crontab crontab -u www-data -e */5 * * * * php -f /var/www/clients/client0/web2/web/cron.php Problem still not resolved. • Add --define apc.enable_cli=1 to cron Problem still not resolved. • Modify apcu.ini Add apc.enable_cli=1 to /etc/php/8.0/mods-available/apuc.ini Problem still not resolved. • Replacing memory caching from APCu to Redis Problem still not resolved. I've tried most of the possible solutions, but the problem hasn't been resolved. Is this a problem because the website owner and group are not www-data:www-data?
Are you running ISPConfig? If you do, start with this: https://forum.howtoforge.com/threads/please-read-before-posting.58408/
Yes, you created a wrong cronjob. Remove the cronjob you manually created under the wrong user. Then log in to ISPConfig and create a cronjob for the website inside ISPConfig. Most likely even a URL cronjob works for this, so you can just put: https://yordomain.tld/cron.php in the command field of the cronjob. If this does not work, create a normal cronjob in ISPConfig.
I can confirm that for running Nextcloud as a site in ISPConfig you can configure Nextcloud to use "Webcron" and set an URL cronjob in ISPConfig as Till has described it with https://yordomain.tld/cron.php as target. Nevertheless for bigger installations Nextcloud suggests to use a "native" cronjob. How to do that correctly I have not been able to figure out. I tried both of these settings but none worked as chrooted cron: Code: php -f /var/www/clients/client1/web8/web/cron.php >>/private/cron.log 2>>/private/cron_error.log /usr/bin/php -f /web/cron.php >>/private/cron.log 2>>/private/cron_error.log Unfortunately the logging to /private/cron_error.log does not work either so I was not able to troubleshoot this in depth.
Code: php -f /var/www/clients/client1/web8/web/cron.php This line can not work, as Cron would not know where to find PHP. Always use the full path to any binary you try to call in a cronjob. For a unjailed cronjob: Code: /usr/bin/php -f /var/www/clients/client1/web8/web/cron.php Code: /usr/bin/php -f /web/cron.php This should generally work when used as a hailed cronjob, but maybe nextcloud tries to access something outside of the jail, which then causes it to fail.
Thanks! I investigated some more, as currently it still does not work with "/usr/bin/php -f /web/cron.php" for me. I created a file /var/www/clients/client1/web8/web/config/cli.config.php to take care of possible problems accessing resources from the jail: PHP: <?phpif(php_sapi_name() == 'cli') { $datadir = '/var/www/clients/client1/web8/private/nextcloud-data'; $CONFIG['dbhost'] = '127.0.0.1'; $CONFIG['datadirectory'] = (is_dir($datadir)) ? $datadir : '/private/nextcloud-data'; $CONFIG['memcache.locking'] = ''; $CONFIG['memcache.distributed'] = '';}?> This should hopefully set the database connection to networking, disable redis use and access the data dir via a path depending on inside vs. outside a jail when a script is called via the CLI. But it does still not work. I had another look around: Whenever the cron job is executed I see the following in /var/log/auth.log: Code: 2023-09-06T21:28:01.310071+02:00 host jk_chrootsh[1021114]: abort, homedir '/var/www/clients/client1/web8' for user web8 (5007) does not contain the jail separator <jail>/./<home> Is the chroot correctly configured for the user? Code: $ cat /etc/passwd | grep web8 web8:x:5007:5005::/var/www/clients/client1/web8:/bin/false
Till wrote in #6 /usr/bin/php ... works for unjailed cronjob. If you have setup website for jailed use, find out what are the paths in that jail for php and the website files.
As I understand it, Till wrote in #6 in continuation the following: This means as long as cron.php does not call things outside the jail it should work like this. But thanks to your answer I tried the following: PHP: <?phpif(php_sapi_name() == 'cli') { echo 'Executed as jailed cron job.';}?> I tried to execute the script above as jailed cron which obviously does not call external resources. That did not work, too, but created the same error in /var/log/auth.log. So I tried a malformed PHP script which should give a PHP error. But that did not happen, as presumably the system does not even reach the execution of the PHP binary due to the error logged. So I suspect there is something wrong with the jailkit installation, although I did set up the whole system by using the ISPConfig autoinstaller in the first place.
What reason do you have to suspect that? To find out the paths inside jail, execute ls commands in the cron job, start with Code: ls -lh / for example and continue from there. Or create jailed shell user to examine what files are where. Directories can be added to the jail, see jailkit documentation and old threads in this forum.
What makes me suspect that something is wrong are the following things when creating a new jailed crontab entry via the web UI and having it run automatically: /var/log/ispconfig/cron.log Code: Sa 9. Sep 18:39:01 CEST 2023 PHP Deprecated: Creation of dynamic property cron_jailkit_plugin::$data is deprecated in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 176 Sa 9. Sep 18:39:01 CEST 2023 PHP Deprecated: Creation of dynamic property cron_jailkit_plugin::$jailkit_config is deprecated in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 177 Sa 9. Sep 18:39:01 CEST 2023 PHP Warning: Undefined variable $parent_domain in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 296 Sa 9. Sep 18:39:01 CEST 2023 PHP Warning: Trying to access array offset on value of type null in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 296 Sa 9. Sep 18:39:01 CEST 2023 PHP Warning: Undefined variable $conf in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 300 Sa 9. Sep 18:39:01 CEST 2023 PHP Warning: Trying to access array offset on value of type null in /usr/local/ispconfig/server/plugins-available/cron_jailkit_plugin.inc.php on line 300 Sa 9. Sep 18:39:24 CEST 2023 PHP Warning: Undefined variable $section in /usr/local/ispconfig/server/lib/classes/ini_parser.inc.php on line 44 Sa 9. Sep 18:39:24 CEST 2023 PHP Warning: Undefined variable $section in /usr/local/ispconfig/server/lib/classes/ini_parser.inc.php on line 44 Sa 9. Sep 18:39:24 CEST 2023 PHP Warning: Undefined variable $section in /usr/local/ispconfig/server/lib/classes/ini_parser.inc.php on line 44 Sa 9. Sep 18:39:24 CEST 2023 usermod: user web8 is currently used by process 640 Sa 9. Sep 18:39:24 CEST 2023 failed to execute usermod -d /var/www/clients/client1/web8/. -s /usr/sbin/jk_chrootsh web8 Sa 9. Sep 18:39:24 CEST 2023 failed to modify user web8 /var/log/cron.log Code: 2023-09-09T18:44:01.394729+02:00 host CRON[1701946]: (web8) CMD (/usr/bin/ls -lh / >>/private/cron.log 2>>/private/cron_error.log #mydomain.de) But no files /var/www/clients/client1/web8/private/cron.log or /var/www/clients/client1/web8/private/cron_error.log are created. /var/log/auth.log Code: 2023-09-09T18:44:01.395399+02:00 host jk_chrootsh[1701946]: abort, homedir '/var/www/clients/client1/web8' for user web8 (5007) does not contain the jail separator <jail>/./<home> I tried it now with "/usr/bin/ls -lh /" and "ls -lh /" as command (having in mind Till's comment regarding the path) - both did not work. What else could I try in your opinion? Thanks!
The problem is that the usermod command failed to set the correct jail path because user web8 seems to be in use in a way that changes for this user are currently locked. You can try to run the command manually, maybe it was just locked temporarily: Code: usermod -d /var/www/clients/client1/web8/. -s /usr/sbin/jk_chrootsh web8
Thanks! Unfortunately that still fails: Code: $ usermod -d /var/www/clients/client1/web8/. -s /usr/sbin/jk_chrootsh web8 usermod: user web8 is currently used by process 1703594 $ ps ax | grep 1703594 1703594 ? S 0:01 php-fpm: pool web8 So PHP blocks the setup?