Home » Php » php – Stop a Laravel scheduled command once stared?

php – Stop a Laravel scheduled command once stared?

Posted by: admin July 12, 2020 Leave a comment

Questions:

So I have set up a scheduled command for a laravel 5.1 project. It works, the command has started, but rather foolishly I didn’t think about how I might stop it. Normally you wouldn’t want to stop it, but the command is inserting nearly half a million rows into a database table, and I only really wanted to make sure I could start it without being logged into the server. I will obviously need to run it at some point but not right now, so is there a way to stop the command mid-flow?

How to&Answers:

This worked for me after I found a fault in my scheduled code and it was going to keep running for a really long time. SSH into the server.

ps -fe | grep artisan

then kill PID (PID being the number of the process). Killing the first two results worked for me.

Note: If you are using withoutOverlapping() the process will not start up again unless you change the ->name() to something unique.