1 week ago

Cron job not updating automatically on live server

Posted 1 week ago by noblemfd

I have this cron job on my Digital Ocean Ubuntu live server:

namespace App\Console\Commands;App/Console/Command

class UpdateCreateEmployeeDepartment extends Command

    protected $signature = 'updatecreateemployeedepartments';

    protected $description = 'Update or Create Employee Department';

    public function __construct()

    public function handle()
        // Select all employees that haven't been updated
        $employees = HrEmployee::where('is_nav_updated', 0)->where('company_id', 1)->get();        

        // For each of the employees selected above
        foreach ($employees as $employee) {
            $department = HrDepartment::where('dept_code', $employee->nav_dept_id)->where('company_id', 1)->first();

            // If a department was found, update the employee
            if ($department) {
                $employee->department_id = $department->id;
                $employee->is_nav_updated = 1;




namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel

    protected $commands = [


    protected function schedule(Schedule $schedule)

    protected function commands()

        require base_path('routes/console.php');

I observed that it's not running automatically as scheduled until when I manually run:

php artisan updatecreateemployeedepartments

How do I resolve this?


Please sign in or create an account to participate in this conversation.