Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 53
Like Tree1Likes

Thread: FAQ: Schedulers [v1.3] - Windows batch file updates

  1. #1
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default FAQ: Schedulers [v1.3] - Windows batch file updates

    Since I have been receiving some questions about the Schedulers, here are some of the more often asked questions:
    Feel free to add questions, concerns or solutions that you come across as you find them!

    Setting up a crontab (Linux) or Scheduled Task (Windows) for SugarCRM

    Linux

    There are some prerequisites the admin will need to fulfill:
    1. Is the PHP binary (either CLI or CGI) in the Apache user's path?
    If you have root user or sudo access to your webserver, login as root then type "su [apache|nobody|your apache user name]". After you have successfully become the apache user, type "php -v".

    If you get some output like "PHP 4.4.1 (cli) (built: May 25, 2005 14:43:03)" then you're done with this step.

    If you get error output like "php: command not found", you'll need to figure out where the binary is by typing "which php". Most secure Linux installations will not allow the apache user to have startup scripts, some won't even allow a home directory. You will need to find out what paths the apache user has access to, and add a symlink to the PHP binary in those paths. Tough eh? Not really.

    Two more steps:
    i. type "echo $PATH" and note what paths are available. Typically, the apache user will have "/bin:/usr/bin:/usr/local/bin" etc. in its path. Now navigate to say "/usr/local/bin".

    If you're still operating as apache, type "exit" to get back to being the root user.
    ii. In /usr/local/bin type "ln -s /path/to/the/php/binary/php ." (this is the same as the output you got from "which php". Okay, done here.
    2. Is the crontab setup correctly?
    Now it is time to double check your crontab entry - still as root, type crontab -e to enter the crontab editor (vi). If the line that Sugar's Scheduler screen is not there, add it now. If it is there, double check that it's formatted correctly:
    Code:
      *   *   *   *   *   cd /path/to/sugar/crm; php -f cron.php > /dev/null 2&>1
    If all is well, you should be able (as the apache user) type in that command above (minus the asterisks) and get some output - AND more importantly, begin using Inbound Email


    From mdougher:
    Here's a little script to run the scheduler and get your emails.

    Set up Admin->Scheduler and select MonitoredEmail every minute.

    Copy the following text into a file (sugarcrmcron.sh) and add it to cron instead of the command line. Change the directories or paths to appropriate for you.

    PATH=/opt/sugarcrm-3.5.1/mysql/bin:/opt/sugarcrm-3.5.1/php/bin:/usr/bin:/usr/local/bin
    LD_LIBRARY_PATH=/opt/sugarcrm-3.5.1/mysql/lib:/opt/sugarcrm-3.5.1/php/lib
    cd /opt/sugarcrm-3.5.1/apache/htdocs/sugarcrm; php -f cron.php

    Setup the following crontab:

    * * * * * /opt/sugarcrm-3.5.1/mattrun.sh >/dev/null 2>&1


    Windows

    Setting up the Windows batch file.
    1. Go to the Scheduler screen in Admin -> Schedulers. At the bottom of the default screen, you will see the contents of the commands you need to add to a batch file. To create a batch file in Windows, open notepad.exe, copy & paste the what Sugar tells you too into a blank file.

    When saving, and this is VERY important, change the Save As Type: dropdown to All Files *.*. Give it any name you want, but make sure the extension is .bat. Test it by double-clicking the batch and making sure you pull down some emails from your inbox.
    PHP 4.x
    If your system has a 4.x flavor of PHP, your PHP-CGI binary is name php.exe and it should be in the root folder of your PHP install folder. This is the one you want to use. In order to it to play nicely with dynamic libraries, you will have to tell it where your php.ini file is located. This can vary from system to system. When in doubt, let PHP tell you - run phpinfo(); and it will return where and which php.ini file it is using. For the example, I will assume that it is located in c:\windows

    A t this point, you need to adjust the pathing to your php.exe binary. It will probaly now look something like this:
    Code:
    c:\path\to\PHP4\php.exe -c c:\windows\php.ini -f cron.php
    PHP 5.x
    If your system has a 5.x flavor of PHP, your PHP-CGI binary is name php-cgi.exe and it should be in the root folder of your PHP install folder. This is the one you want to use. In order to it to play nicely with dynamic libraries, you will have to tell it where your php.ini file is located. This can vary from system to system. When in doubt, let PHP tell you - run phpinfo(); and it will return where and which php.ini file it is using. For the example, I will assume that it is located in c:\windows

    A t this point, you need to adjust the pathing to your php.exe binary. It will probaly now look something like this:
    Code:
    c:\path\to\PHP5\php-cgi.exe -c c:\windows\php.ini -f cron.php
    2. Once saved, create a new Scheduled Task through Start -> Control Panel -> Scheduled Tasks -> Add Scheduled Task.

    Go through the wizard. Select the batch file you just created by Browse'ing for it.

    At the next screen, have it perform Daily. Select the defaults as needed (remember to give it a good User/Password when it gets to that screen), and then make sure you check off Open advanced properties for this task when I click finish.

    When Advanced Properties opens, go to the tab named Schedule and then click the Advanced... button.

    Check off Repeat task to enable the fields below it, and have it repeat Every Minute (or whatever you find appropriate. Save your changes and enjoy!
    Schedulers Fixes in 4.0.1

    New job-eligibility algorhythms determine what job should run at a given time, not based on a list (the "Active Jobs" subpanel when looking at a Job), but at runtime. This will make the Scheduler module much more robust.
    What does each Job do?
    refreshJobs -- now deprecated as of 4.0.1
    This job, intended to run every 12 hours, goes through all the active scheduler jobs and creates entries for the schedulers_times table, allowing admins to track progress, successes and failures. It would be faster to implement if I had gone the standard route without using tables, but then auditing what was [not] happening would be very difficult.
    pollMonitoredInboxes
    This job is InboundEmail specific, as it is the "auto-magical" part of our I-E module. It polls all active mailboxes that have been set up for your organization.
    runMassEmailCampaign
    This job replaces emailmandelivery.php. If you have this job setup, you can delete the old crontab entries as well as that file itself as it is now deprecated.
    pruneDatabase
    This job goes through every table in you Sugar database, finds records that have been soft-deleted (deleted = 1), creates a large SQL file, and physically deletes those records. It is mostly a performance job, and is not essential to the use of Sugar.

    The backup files are placed in cache/backups with timestamped filenames.
    pollMonitoredInboxesForBouncedCampaignEmails
    This job polls any mailbox set up as type Email Campaign Bounce and monitors for bounces, and is an essential component of Mass Email Campaign monitoring - check out the reports screens in the Mass Email admin screen! They are really cool!
    processWorkflow
    This job is for Pro/Enterprise customers only. This is the timed component for the Workflow module - so if you set a timed trigger for an event, say a Lead becoming one week old, then it will find the predefined Workflow actions and fire them when appropriate.
    Last edited by sugarchris; 2006-03-28 at 10:13 PM.

  2. #2
    nmpaulcp is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    38

    Default Re: FAQ: Schedulers [v1.0]

    I have Zucker Mail running now Chris but I wanted to try using the Sugar incoming email. I looked at the schedulers and I found the pollMonitoredInboxes job which appeared to be setup except the days were not selected, When I went to save all days it gave me a message that the days were not selected. I made a new Scheduled job for the pollMonitoredInboxes and it let me save it. Also refresh jobs is saved. Both jobs are active and status shows as ready but they do not excecute. I am guessing that the message i have:
    To Setup Windows Scheduler
    Create a batch file with the following commands:
    cd C:\Program Files\xampp\htdocs\Sugarcrm
    php.exe -f cron.php
    is the problem.
    Is there any guide as to how to do this? I can use the Zuckermail but would like to try the functionality of the Sugercrm incoming mail module!
    Also I tried runnig the incoming as IMAP and it gives me a log in unknown user message when I test it But POP3 works fine.
    Thanks for all your help.
    Paul
    Last edited by nmpaulcp; 2005-12-29 at 04:07 PM.

  3. #3
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Updated the FAQ with some setup hints.

    Hope this gets you underway!

  4. #4
    wald is offline Junior Member
    Join Date
    Dec 2005
    Posts
    1

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Thanks Chris for explaning the setup of the crontab. I've checked the steps as you've descriped - I've created a link (SuSE 9.3) frm usr/local/bin - to usr/bin/php. I've modified the crontab (etc/crontab) without asterix with pointing the path to the right directory - and the sugar scheduler still shows: last run: never.

    As I have no idea what I did wrong and as I beleive that a lot of other guys have or will have the same problems I post this problem in this forum.

    Hopefully you can give a bit more detailled steps how to setup the sugar mail functionality.

    Thanks and best regards
    wald

  5. #5
    nmpaulcp is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    38

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    I just setup scheduler also in windows all went well it seems but I still have Last run on both function:ollMonitoredInboxes and function::refreshJobs as "never" also.
    ps Not trying to imply that Chris is giving us bad info! I am sure there are some other things I could check if I had some more knowledge of these programs. I am really impressed on how the rest of the program is working. It runs very fast on my Windows Server 2000. If I have to I will just stick with Zuckermail till I get this issue worked out.

  6. #6
    thielj is offline Junior Member
    Join Date
    Dec 2005
    Posts
    1

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Hi Chris,
    we needed the following patch to get the Scheduler and Inbound Email working:

    Code:
    diff -cr SugarSuite-Full-4.0.0-original/cron.php SugarSuite-Full-4.0.0/cron.php
    *** SugarSuite-Full-4.0.0-original/cron.php	Fri Dec 16 07:39:04 2005
    --- SugarSuite-Full-4.0.0/cron.php	Thu Dec 29 20:56:29 2005
    ***************
    *** 37,43 ****
      
      
      
    ! if(empty($GLOBALS['log'])) { require('log4php/LoggerManager.php'); }
      if(empty($sugar_config)) { require_once('config.php'); }
      $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
      
    --- 37,43 ----
      
      
      
    ! if(empty($GLOBALS['log'])) { require_once('log4php/LoggerManager.php'); }
      if(empty($sugar_config)) { require_once('config.php'); }
      $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
      
    diff -cr SugarSuite-Full-4.0.0-original/schedulers.php SugarSuite-Full-4.0.0/schedulers.php
    *** SugarSuite-Full-4.0.0-original/schedulers.php	Fri Dec 16 07:39:13 2005
    --- SugarSuite-Full-4.0.0/schedulers.php	Thu Dec 29 21:03:01 2005
    ***************
    *** 34,40 ****
      require_once('include/dir_inc.php');
      require_once('include/utils/file_utils.php');
      require_once('config.php');
    ! if(empty($GLOBALS['log'])) { require('log4php/LoggerManager.php'); }
      if(empty($sugar_config)) { require_once('config.php'); }
      $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
      
    --- 34,40 ----
      require_once('include/dir_inc.php');
      require_once('include/utils/file_utils.php');
      require_once('config.php');
    ! if(empty($GLOBALS['log'])) { require_once('log4php/LoggerManager.php'); }
      if(empty($sugar_config)) { require_once('config.php'); }
      $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
    There are also a few other issues related to Email that keep us from putting SugarCRM into use:

    • Internet Explorer 6.0 doesn't always show the HTML message body
    • QP encoded header fields are not properly read. This might be irrelevant to the US, but is essential for every non-english speaking country
    • I.E. converted to Lead: The reply is missing the original Subject
    • Polling per-user mailboxes would be very nice to have
    • In outbound email, we didn't manage to get the Reply-To: field working (it's always the same as From). It would be nice to have the actual user as sender (From), with Reply-To set to the group's mailbox


    Best reagrds,
    Jens.

  7. #7
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Hi Jens,

    Thanks for looking into these issues.
    Quote Originally Posted by thielj
    Hi Chris,
    ...
    • Internet Explorer 6.0 doesn't always show the HTML message body
    • QP encoded header fields are not properly read. This might be irrelevant to the US, but is essential for every non-english speaking country
    • I.E. converted to Lead: The reply is missing the original Subject
    • Polling per-user mailboxes would be very nice to have
    • In outbound email, we didn't manage to get the Reply-To: field working (it's always the same as From). It would be nice to have the actual user as sender (From), with Reply-To set to the group's mailbox
    1. The IE6 bug is a tough one - the compose email screens were put into use before I was hired here, and we've "addressed" them several times - enough that they display consistently internally, but the issues don't get permanently fixed. However, we are examining them carefully - enough to now consider changing the code for something more reliable.

    2. QP is an issue that we don't run into very often. When you write QP encoded header fields, do mean that all the text in the headers is QP encoded? Or is it just display text such as the subject and/or body? I have a method that deals with encoding, specifically for attachments (which QP is a switch case), but since I don't have example emails, it's very difficult to diagnose. Could you send some example emails to test@toastedpixel.com? That is my test email account when I develop for Inbound Email.

    3. The Lead conversion reply email missing it's subject line is a bonafide bug. I've created one for myself. You can track it here: http://bugs.sugarcrm.com.

    4. Individual user mailboxes was originally designed in. NO ONE was more disappointed than myself that it was cut from 4.0! Now that the functionality is obviously so highly desired, the manager-level has told me to re-implement it. Sigh. Don't worry, it's coming

    5. This has been somewhat addressed in the design spec. In the reply to an I-E, there is a check-box next to the FROM field. This toggles between the reply-to address you set in the "Create Mailbox" screen and the user's own reply-to name/email.

    Thanks again for taking such a detailed look into this issue. I would appreciate a bit of assitance for the QP issue since I cannot replicate the issue here.

  8. #8
    Zucker Fan is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    10

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Not sure how this applies to other Linux distributions, but I edit my crontab directly through vi and had to add user to the line item in order to get it to work. I am running Fedora Core 4.

    Code:
    *   *   *   *   *  root  cd /path/to/sugar/crm; php -f cron.php > /dev/null 2&>1
    Marc

  9. #9
    edelapatte is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    24

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Hello all,
    I have done all the checkin as stated at the beginning of this faq and received the right answers. But still no incoming email. So I checked the error-log and it says:
    [Thu Jan 05 14:12:01 2006] [error] [client xxx.xxx.xxx.xx] PHP Notice: Undefined variable: sugar_config in /.../.. /httpdocs/sugarcrm/modules/Schedulers/SchedulerDaemon.php on line 733

    What is the sugar_config variable that is undefined?? Do I have todo anything more than managing monitoring mailboxes and get cronjobs running.

    Anybody an idea !!!

    Thanks,
    Ed

  10. #10
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: FAQ: Schedulers [v1.1] - crontab/Windows Scheduled Task setup

    Hi edelapatte,

    Where you see this, (around line 733):
    PHP Code:
    ...
    /**
     * This function drops all rows in the schedulers_times table.
     */
    function dropSchedules($truncate=false) {
    ... 
    add:
    PHP Code:
    ...
    /**
     * This function drops all rows in the schedulers_times table.
     */
    function dropSchedules($truncate=false) {
        global 
    $sugar_config;
    ... 

Page 1 of 6 12345 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •