How to set up cron job for osTicket? What cron job setting shall I use?

Question:

I installed osTicket on my server, and I want to set up a cron job to trigger osTicket’s cron job script. What should I do to set up the cron job?

Answer:

Our webcron service is best for triggering osTicket’s cron job script. Just follow below simple steps to configure cron job for your osTicket:

  1. Find rcron.php in “scripts” folder and change:

    1) line 24 from

    'url'=>'http://yourdomain.com/support/api/tasks/cron',

    to

    'url'=>'{your osticket installed location}/api/tasks/cron',

    NOTE: Don’t change “/api/tasks/cron”!

    2) line 25 from

    'key'=>'API KEY HERE'

    to

    'key'=>'your generated API key'

    NOTE: Please use your web server’s IP (on which your osticket was installed) to generate the API key. Check below:


    Set up osTicket API key

    Edit the osTicket rcron.php file
  2. Rename the filename from rcron.php to a secret name (for example 123rcron.php). Or you can upload it to a secret location on your web server later without changing the filename.

  3. Upload 123rcron.php to your web server (to any location that can be accessed via HTTP). For example, http://www.example.com/123rcron.php.

  4. Open your

    , click on “Create New Cron Job” button.

  5. In field “URL to call”, enter http://www.example.com/rcron.php (replace www.example.com with your install location). Choose an appropriate cron job execution frequancy (for osTicket, we recommend to have the cron job run “every 5 minutes”). Checkout below screenshot:

    Set up cron job for osTicket
  6. If necessary, finish the other optional settings.
  7. Click “Create Cron Job” button. You’re done! EasyCron will trigger your osTicket’s cron job script dutifully according to your time setting.
  8. If you haven’t registered your EasyCron account yet, click on the “add a password” link on the top to add an email and password to your account.

i have a problem with cron not working i get the following: — Parse error: syntax error, unexpected T_FUNCTION in /home/thedust2/public_html/help/include/class.ticket.php on line 1923 #351

Open
dustinco opened this issue on 22 Dec 2013 · 14 comments

5 participants

@dustinco@greezybacon@clonemeagain@protich@billwynne
@dustinco

No description provided.

@greezybacon

osTicket member

@dustinco

My php version is 5.3.27

@clonemeagain

Does cron see the same version? Because you will need 5.3+ for that code to run. (Uses anonymous closure syntax http://www.php.net/manual/en/functions.anonymous.php).

You will have to check that your php cli executable has a greater version than 5.3, this is different to the apache mod_php or fcgi module.. ie, open a terminal and enter the command:

php -v

It should print out the version:

PHP 5.4.9-4ubuntu2.4 (cli) (built: Dec 12 2013 04:29:20) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

Notice the (cli) in there.. Yours will probably not match mine exactly, but the first bit is the important bit: PHP 5.??

@dustinco

below is the terminal information

PHP 5.3.27 (cli) (built: Sep 5 2013 11:29:45)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader v4.4.1, Copyright (c) 2002-2013, by ionCube Ltd.

@protich

osTicket member

@dustinco – Do which php and make sure the resulting executable is the same as what is on crontab entry.

@dustinco

do you mean.. type in which php via terminal and verify the php location?

/usr/local/bin/php

if so than it is what im using.

if not please explain a little more.. Im new at this but know a few things.

@clonemeagain

This is my crontab entry:

*/5 8-18 * * 1-5 nobody /usr/bin/nice -n 19 /usr/bin/php /var/www/support/api/cron.php

So, yours should be similar, but using /usr/local/bin/php right?

Is there any chance you could upgrade php?

Or, perhaps it is just that function definition, this might fix it:

        // Don't enforce form validation for email
        // old style code for <5.3
        // Ultimately, only offer validation errors for web for
        // non-internal fields. For email, no validation can be
        // performed. For other origins, validate as usual
         $field_filter = create_function($f,"   
                switch (strtolower($origin)) {
                    case 'email':
                        return false;
                    case 'web':
                        return !$f->get('private');
                    default:
                        return true;
                    }
        ");

Unsure though if the vars will be in scope or not.. haven’t tested, can you?

@dustinco

upgrade to 5.4.17? I will do that now and I will report back.
my crontab is

*/5 * * * * /usr/local/bin/php /home/thedust2/public_html/help/api/cron.php

@billwynne

@dustinco – From the looks of that path you are on Hostgator? I am struggling to get osticket 1.8 working right now.

Here is the error being emailed to my

Parse error: syntax error, unexpected T_FUNCTION in/home3/btwynne/public_html/leadcapturepagebosshelp.com/include/class.ticket.php on line 1923

Help is much appreciated.

@dustinco

@billwynne

ok, did you sort this issue out?

@dustinco

@billwynne

ok, thanks.

@billwynne

Here was my fix using Hostgator and getting the same error. The problem was the PHP on the cron was not the same as the PHP on the server. Here is the solution in my case:

For those of you that use Hostgator and are trying to use osticket 1.8 here is the scoop, well two scoops.

  1. In your htaccess file in your root you need to add the following code and not everyone is on home3 so look on the left hand side of your cpanel main page.

Attaching an image of the code since it is not allowing the code here.

screen shot 2014-01-15 at 7 55 30 pm

  1. Setup this for a cron job:

*/5 * * * *

/opt/php53/bin/php /home3/username/public_html/leadcapturepagebosshelp.com/api/cron.php

In this case leadcapturepagebosshelp.com is an add-on domain. If you just have one primary domain there would be nothing to place here, unless you were installing osticket on a subdomain.

Categorizado em: