I'm running a simple PHP process that uses a tiny bit of memory and CPU. The max memory limit is 2G and the script is run from console.

The memory used never exceeds 200 MB. CPU use fluctuates between 10 - 80% of a single core.

At random, the process will be killed with message Killed: 9. There is nothing else given in the error message in the console and nothing appears in the logs.

This even happens if I pause the script using XDebug so that no additional memory can be used.

This happens if I disable Xdebug as well, so I don't suspect that is the culprit.

I've tried rebooting, but still happens.

The PHP script simply pulls a list of ads from Facebook using their PHP SDK v3.2 and then adds them to a database. There is only one worker running. Very simple process.

I have 32 GB RAM and 1TB HD. Running PHP 7.2 with nginx, MySQL 5.7 and redis.

My sw_vers output:

ProductName:    Mac OS X
ProductVersion: 10.14.2
BuildVersion:   18C54

System Integrity Protection status: enabled

This is the essence of the script:

$ads = $this->getApiAdAccount()->getAds($fields, $params);


if (!$ads->valid()) {
    return false;

while ($ads->valid()) {
    $adData = $ads->current()->getData();

    try {
        if (!Campaign::find($adData['campaign'])) {
            dispatch(new ImportCampaign($adData['campaign']));

        Ad::updateOrCreate(['id' => $adData['id']], $adData);
    } catch (\Exception $e) {


There is no specific spot it fails. I can run the Laravel job worker (redis queue) to process the code and insert/update the tiny array of data it processes on each loop.

How can I trace the source of this crash?

I've tried dmesg and dmesg | grep -E -i -B100 'killed process' as suggested elsewhere, but no useful information comes out.

  • 1
    Does it say anything else than “Killed: 9”. Unless you have used all swap on the computer, memory usage should not lead to processes being killed with signal 9. I would look elsewhere for the cause. What is the name of your script? What is the purpose of the script / what does it do? Which command exactly do you use to start it? Do you start it from Terminal.app? Do you keep that terminal window open? – jksoegaard Mar 7 at 9:50
  • What does sw_vers show for your build / version and how is SIP configured? – bmike Mar 7 at 10:22
  • You might also need to just show a minimal version of how your PHP script runs. I would have to make a lot of assumptions to even try to reproduce your issue. With a little data, someone might be able to point out The quick answer. – bmike Mar 7 at 10:24
  • @bmike I've updated my description with more information. – ShrewdSimian Mar 7 at 16:55
  • @jksoegaard I've updated the description with your request. I'm using iTerm2 for my console. I'm running php artisan queue:work redis --queue=facebook under Laravel 5.6. The window remains open for the entire process so I can watch for any errors. – ShrewdSimian Mar 7 at 16:56

The behavior you're seeing is not a problem with the hardware, the operating system, or lack or resources.

Instead it is simply the way that Laravel queueing works. If the worker takes too long to process a job, there's a timeout and the worker is killed with signal 9. Similar if the memory usage exceeds a set amount, the worker is killed.

You can set these limits with for example the --memory option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .