How to track issues with Sugar Cron ?

Hi guys,

I was wondering how you manage the potential issues and warning with Sugar Cron scripts ?

because, with the out of the box lines provided everything is re-routed to /dev/null.

The problem to re-route to a log file are that some job produced a lot of info, warning etc. and not really errors.

Any suggestion is welcome.

Fred

Parents
  • Disclaimer: I am old school and work in vi and command line on my servers all the time. No IDE. We are OnSite and have a lot more flexibility than cloud instances and what I am sharing here are likely far from the best tracking systems, but they have been working for me for about a decade.

    - I changed the Cron to track errors in a cron.raw.err file in a subdirectory of logs; my sysadmin set up a logrotate on his end so that it does not grow too large. Caveat: You need to know to tail the log when the cron job is running or go back to it regularly to see what is happening there. So it's basically there when I needed it but provides no "warning" that something is up.

    - for schedulers that are Sync jobs where we need much more insight we have separate logs written in another subdirectory of logs, for each run, named as the scheduler name and timestamped, we then have a separate system cron job (outside of Sugar) that zips older logs and deletes the gz files older than x-days so we don't have a ton of logs (we keep about 3 days worth).
    These are not reporting "errors" though, these are more like debug statements included in the scripts to track where things are so we can debug particular records that have problems syncing. Again, created more than a decade ago, this is not something we look at often and we are working to get away from. The cron script itself will not re-run if there is a log open for the prior run (that means it's still running or it got stuck) and it helps us debug records that are not syncing for some reason (sadly that happens way more than I would like). I have a custom web page on my sugar server, linked from the mega menu for admins, that shows these logs so I can see if one has been "stuck".

    - I also have a scheduler that queries the job_queue and send me an email with all the jobs that failed in the last hour which includes the sync jobs above if they time out. This is pretty crude and was built back in v6 as an Entry Point and essentially executes a query on job_queue and composes an email to Sugar Admin (UserID = 1) with the failed schedulers and the "resolution" field content which occasionally gives a hint of what's wrong.

    $query = "SELECT * FROM job_queue WHERE resolution = ? and execute_time > DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
    $conn = $db->getConnection();
    $stmt = $conn->executeQuery($query, array('failure'));
    $rows = $stmt->fetchAll();

    Finally, I sometimes watch the logs. Yes, I tail the sugar log and the php log on my production system keep them open in a corner of my desktop so it catches my eye when something is logged (moves on the screen) and I can see what it is and decide if it needs action now or later, or if I can live with it/do nothing about it. My PHP logs are set to include Warnings and Notices so I see it all. 
    To be honest, I really don't do this as often as I should.

    FrancescaS

  • Hi  ,

    Thank you for your detailled feedback, that confort me in the way we are working. Our concern is really to enhance our customer supervision, including "normal errors" (those which are catched and visible in the sugarcrm.log) and "other errors" (warning or error during cron execution for instance etc.).

    Your last idea (track the job_queue jobs that failed) is a real good idea that we will probably use for our customers supervision.

    Thanks for you feedback

    Fred

Reply Children