• 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

Input Scheduled Task with "Run a PHP Script" throws errors if using short open tags

Chad Reitsma

New Pleskian
Hey guys,
I ran into a weird issue when using a scheduled task on one of our client's Wordpress installations.

Some background information:
  1. The scheduled task is set up as "Run a PHP Script" without arguments.
  2. We have changed the 'Access to the server over SSH' to /usr/bin/bash
  3. PHP Options - Use short open tags is "ON"
  4. The full command inside of crontab is: /opt/plesk/php/7.4/bin/php -f 'httpdocs/rebill.php'
Upon execution it threw some crazy PHP errors about T_ENDFOREACH and T_ELSE. On further investigation the only thing I could see was that we were using short PHP open-tags <?, after replacing these with the full <?php open tags, everything was fine.

But Short open tags are set to "ON" inside of the domain's PHP settings.

I'm guessing it's not using those settings because it's being executed directly from the command-line.
 
You're probably right. To tackle this issue I suggest to add a "-c" parameter and the path to the php.ini file to the command line. It should then run with the options you define in that .ini file.
 
You're probably right. To tackle this issue I suggest to add a "-c" parameter and the path to the php.ini file to the command line. It should then run with the options you define in that .ini file.
Thanks Peter! I thought about that too.
Where does Plesk store the php.ini for each domain?
 
I not entirely sure but it looks like domain specific PHP settings are not used in cronjobs. Not sure if thats by design. The suggestion from @Peter Debik is a good workaround.

If you feel it's a bug then you're welcome to submit a bug report :)
Thanks Rasp, I don't think it's a bug - I just wanted to create this post to help any novice devs. It might confuse them because the code is technically sound, it's just running with a different config.
 
Back
Top