• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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