I have in root folder of my joomla website a php where i load joomla framework and create a xml output file, the first lines before i do a db request are:

define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__)));

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

If i run this file i get a well generated xml file, that's ok. but i need to set a cronjob for it, if i try to run cron job, i get this error message:

/PATH/my_file.php: line 1: ?php: No such file or directory
/PATH/my_file.php: line 2: syntax error near unexpected token `'_JEXEC','
/PATH/my_file.php: line 2: `    define( '_JEXEC', 1 );'

What i need to fix to get a correct cron job?

  • Can you please show the command you're using for your cron job?
    – Lodder
    Sep 26, 2014 at 10:11
  • Here in the screenshot you can see my settings: prntscr.com/4qfkgr
    – jExchange
    Sep 26, 2014 at 10:19

1 Answer 1


You will need to define the path, starting from the very root of your server. Try changing the command to the following:

php /home/XXXX/public_html/my_file.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.