With Scheduled tasks and jobs running in the background it can sometimes
be difficult to determine what is going on when things go wrong. If you
are debugging a scheduled task the the scheduled task page is a good
place to start. For both scheduled tasks and job queue tasks you can
also check the job_queue table. For example, in MySQL we can check the
last five scheduled jobs:
Example 13.7: Example MySQL query for listing jobs
SELECT * FROM job_queue ORDER BY date_entered DESC LIMIT 5
This will give us information on the last five jobs. Alternatively we
can check on specific jobs:
Example 13.8: Example MySQL query for listing BeanEmailJobs
SELECT * FROM job_queue WHERE target = 'class::BeanEmailJob'
In either case this will give details for the job(s):
Example 13.9: Example MySQL list of jobs
*************************** 1. row ***************************
assigned_user_id: 1
id: 6cdf13d5-55e9-946e-9c98-55044c5cecee
name: Email job for Accounts 103c4c9b-336f-0e87-782e-5501defb5900
deleted: 0
date_entered: 2015-03-14 14:58:15
date_modified: 2015-03-14 14:58:25
scheduler_id:
execute_time: 2015-03-14 14:58:00
status: done
resolution: success
message: NULL
target: class::BeanEmailJob
data: {"id":"103c4c9b-336f-0e87-782e-5501defb5900","module":"Accounts"}
requeue: 0
retry_count: NULL
failure_count: NULL
job_delay: 0
client: CRON3b06401793b3975cd00c0447c071ef9a:7781
percent_complete: NULL
1 row in set (0.00 sec)
Here we can check the status, resolution and message fields. If the
status is queued
then either the scheduler has not yet run or it isn’t
running. Double check your Cron settings if this is the case.
It may be the case that the job has ran but failed for some reason. In
this case you will receive a message telling you to check the logs.
Checking the logs usually provides enough information, particularly if
you have made judicious use of logging (see the chapter on logging) in
your job.
It is possible that the job is failing outright, in which case your
logging may not receive output before the scheduler exits. In this case
you can usually check your PHP logs.
As a last resort you can manually run the scheduler from the SuiteCRM
directory using:
Example 13.10: Running the scheduler manually
Using this in addition to outputting any useful information should track
down even the oddest of bugs.