PawelPaciorek

Then you need to check all of your logs and run the command manually to see what's going on.

Cheers.

4 days later

Hi, I added the following code to the file in cron.php in the api directory:
<?php

// Add correct path to your countlog.txt file.
$path = 'hits.txt';

// Opens countlog.txt to read the number of hits.
$file = fopen( $path, 'r' );
$count = fgets( $file, 1000 );
fclose( $file );

// Update the count.
$count = abs( intval( $count ) ) + 1;

// Output the updated count.
echo "{$count} hits\n";

// Opens countlog.txt to change new hit number.
$file = fopen( $path, 'w' );
fwrite( $file, $count );
fclose( $file );
?>

I also added the hits.txt file there
The code itself works, I checked.(in the public_html directory)
But when triggered by cron, should the counter in the hits.txt file be incremented, or will it not work?
currently the counter in the hits.txt file does not change.

    PawelPaciorek

    Unfortunately, I'm not going to be able to assist with custom cron scripts.

    Are you sure you are calling the correct location/file? Have you tried running the cron command manually via CLI to see if any errors are being returned (eg. /path/to/php /path/to/osTicket/api/cron.php)?

    Cheers.

    When i run cron, i get this errors:
    Stack trace:
    #0 /home/users/user-name/public_html/domains/domain-name/public_html/main.inc.php(23): require()
    #1 /home/users/user-name/public_html/domains/domain-name/public_html/api/api.inc.php(23): require_once('/home/users/user-name...')
    #2 /home/users/user-name/public_html/domains/domain-name/public_html/api/cron.php(17): require('/home/users/user-name...')
    #3 {main}
    thrown in /home/users/user-name/public_html/domains/domain-name/public_html/bootstrap.php on line 344
    PHP Fatal error: Uncaught Error: Non-static method Misc::currentURL() cannot be called statically in /home/users/user-name/public_html/domains/domain-name/public_html/bootstrap.php:344

    My cron.php file
    <?php
    /*********************************************************************
    cron.php

    File to handle LOCAL cron job calls.
    
    Peter Rotich <peter@osticket.com>
    Copyright (c)  2006-2013 osTicket
    http://www.osticket.com
    
    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.
    
    vim: expandtab sw=4 ts=4 sts=4:

    **********************************************************************/
    @chdir(dirname(FILE).'/'); //Change dir.
    require('api.inc.php');

    if (!osTicket::is_cli())
    die(__('cron.php only supports local cron calls - use http -> api/tasks/cron'));

    require_once(INCLUDE_DIR.'api.cron.php');
    LocalCronApiController::call();
    ?>

      PawelPaciorek

      To me it seems like you are using an older version of osTicket or an unsupported version of PHP. What is your osTicket version and what is your PHP version?

      Cheers.

      Hello,
      PHP 5.4 [LEGACY]

      Apache
      Database client version: libmysql - mysqlnd 8.1.10

      PawelPaciorek

      Wow, that’s an extremely old version of PHP. I would highly suggest upgrading your PHP and osTicket and retest.

      Cheers.

      6 days later

      PawelPaciorek

      I’m sorry but without you being on a latest release with the latest supported prerequisites then I wouldn’t be able to assist you further.

      Cheers.

      Here is the list of current versions and their pre-requisites.

      a month later

      ok, i upgrade osticket to 1.18.1 and still have the same problem, all works without auto email notificaton.
      Notification is send only when administrator login to do panel...

        PawelPaciorek

        Can you share a screenshot of Admin Panel > Dashboard > Information? Your situation doesn’t really make any sense unless only auto-cron is running which is only ran when agents are logged in.

        What alerts are not sending exactly?

        Cheers.

        PawelPaciorek

        Also, did you update the cron command to reflect the new PHP version after upgrading? If not that will be an issue.

        Cheers.

        Previously it worked like this:
        Someone sends an email to a mailbox connected to osticket.
        Osticket downloads this message and creates a report, sending an emain to the website address about the new report and its content.

        Currently it works like this:
        Someone sends an email to a mailbox connected to osticket.
        Nothing further happens until I log into my account.
        When you log in, osticket creates a ticket and sends an email notification that the ticket has been created.

        my cron job looks like this, before this works...

        • * * * * /usr/bin/php /path_to_osticket_folder/public_html/api/cron.php

          PawelPaciorek

          Why didn’t you check the requirements before upgrading? We don’t support PHP 8.3 so you’ll need to downgrade to PHP 8.2 and update the cron command accordingly.

          After your recent description of the issue I can confirm your cron job is not running or is not correct which is the cause of your issue.

          Cheers.

          OMG... today i change php version to 8.1 and cron start working but only for 2 minutes, and now doesnt work...

            PawelPaciorek

            As suggested earlier in this discussion, try using the following cron command (this runs every 5 minutes):

            */5 * * * * /path/to/php /path/to/osTicket/api/cron.php

            Of course, you’ll have to replace /path/to/php with the full path (or short-name) for your PHP executable (ensure it’s the same PHP version you are running osTicket on) and replace /path/to/osTicket/api/cron.php with the full path to your osTicket /api/cron.php file.

            Cheers.

            Write a Reply...