Skip to content

Command and job not executing completely #23728

@jfelipeara

Description

@jfelipeara
  • Laravel Version: 5.5
  • PHP Version: 7.1
  • Database Driver & Version: mysql 5.7

Description:

I have a command that runs a scraper from some website and send a slack notification, it is a cron job and it works fine most of the times here is the code:

try {
            if (!Cache::has('scraper-database')) {
                Cache::forever('scraper', 'proccesing');
                $lines = shell_exec('node /home/jfelipeara/htdocs/administrator/resources/assets/js/scraper/index.js');
                $sims = json_decode($lines, true);
                $verifier = new BalanceVerifier($sims);
                $verifier->verify();
                Cache::forget('scraper');
            }
        } catch (Exception $e) {
            Cache::forget('scraper');
            Log::error('Scraper catch an exception: ' . $e->getMessage());
            Log::error('trace: ' . $e->getTraceAsString());
        }

when i run the command manually it works fine, when i use schedule it works fine, but some times the cache key doesn't delete and it doesn't catch any error and i have to clear it manually so it run again next time. Also it does everthing it have to do, except for the cache clearing.

I also have a button that call the command to run the scraper but the shell_exect always return null, i tried make a job with the same code and push it to a queue but no luck, it says it processed but i doesnt event pass the shell_exec.

Hope anyone can help. thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions