Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[resolved] Error when executing cron job


in order to import email messages to osTicket v1.9.15 even when no agent is logged in, I setup a cron job according to your instructions. For my hosting provider and how I placed the osTicket files on the server I had to place the following command in my hosting provider's crontab file:
*/5 * * * * /usr/bin/php5 /kunden/homepages/38/d32651925/htdocs/osticket-v1.9/api/cron.php

But when this command executes I get the following error message:
X-Powered-By: PHP/5.2.17
Content-type: text/html

<br />
<b>Parse error</b>:  syntax error, unexpected ':' in <b>/homepages/38/d32651925/htdocs/osticket-v1.9/bootstrap.php</b> on line <b>330</b><br />

Interesting for me is that it seems that the bootstrap.php is executed and not the api/cron.php. And looking into line 330 of bootstrap.php there is a colon included indeed. But removing that does not remove an error, then just another will come up.

Thus what steps should I do next for error resolution?

Best regards, Harold


  • Well, bootstrap is initialized by all forms of osTicket in order for it to work. If the rest of it works, then I wouldn't be changing bootstrap.php just for cron, I'd be more inclined to believe it was a PATH issue, that cron didn't have the correct environment to run the script properly.

    I checked github for that file (Your version is a bit out of date, maybe update?), that line contains normal PHP, valid since 5.3, so if it's not working, then your version of PHP is way out of date. Perhaps you should see if there are others installed? Who is your host?  Ahh, yes, I see, 5.2.17! woah, FYI 5.3 came out in 2009. 
    5.2 hasn't been supported by PHP for over six years.. holy crap. 

    Hopefully for your sake your host HAS upgraded, (you'd know, because osTicket wouldn't work at all), and it's simply the /usr/bin/php5 symlink that is pointing to an archaic version, try changing it to /usr/bin/php that might be up to date?
  • Hello Grizly,
    thanks for your reply. osTicket v1.9.15 is running via PHP 5.6 at my hosting provider. I can select 5.6, 7.0 and 7.1. But osTicket v1.9.15 only runs with PHP 5.6.
    Thus your reply suggests that I try to find a symlink to a newer version for the cron job. I already tried it with /usr/bin/php but this one does not exist.
    It looks like that I have to get into contact with my hosting provider's support.
    Again many thanks for your prompt reply.
    Cheers, Harold
  • Well, the header in the message you sent indicates that the PHP version isn't 5.6:

    X-Powered-By: PHP/5.2.17

    That's not 5.6 mate. 

    That being said, you shouldn't be seeing HTML errors for php-cli anyway. Maybe there is a CLI binary you can use instead? Maybe they haven't installed the cli version? In which case, you can get around it with the API itself, simply enable remote cron via /scp/apikeys.php click "Add a new API key", enter the IP address of the server, or, then as per to call it. 

    */5 * * * * nobody /usr/bin/wget -q -O /dev/null --user-agent=<API key here> http://<host & path goes here>/api/cron.php

  • "PHP/5.2.17"

    This is a problem.
  • Thanks for all your replies. I now found the symlink to execute the script with PHP 5.5. Now it works!
  • Glad that you got this sorted.  I am marking this as resolved and closing it.  Please feel free to start a new thread if you have another question, comment, feedback, etc.
This discussion has been closed.