Move files with a custom scheduler job

Hello Everyone,

I have a script that transfers data from csv files to sugarcrm.

Everything works properly except that I want to move the files after being successfully processed from folder "Queue" to folder "Processed".

function move_file_to_proccessed($file) {
  $src = "Queue/".$file;
  $dest = "Processed/".$file;
  $res =  rename($src$dest);
}

This function should be enough to do the job, when I run it locally it does exactly that. But when the scheduler runs through sugar the files do not move from Queue to Processed.

Does sugar impose any sort of limitations on file related functions in PHP ?

Also this sugar instance is locally hosted and is licensed as Enterprise v9.0.1

Thank you in advance

  • Hi Simo,

    Sugar cloud has limitations on file functions, but snice you say it's self-hosted, there shouldn't be any restrictions, as long as you're able to deploy your code.

    But - when the cron runs, the root folder is the Sugar root folder. Based on that, a few checks that you can try:

    1. Are your "Queue" and "Processed" folders available in Sugar root folder?

    2. Are the file names and folder names in the same case? Windows ignores case, but Unix/Linux servers will require the exact case.

    3. Does your apache process have access to the Queue/Processed folders?

  • This is it! Thank you very much. The problem was Queue and Processed were not in the root folder.