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?
By default, scheduled tasks will be run even if the previous instance of the task is still running. To prevent this, you may use the withoutOverlapping method: $schedule->command('emails:send')->withoutOverlapping(); In this example, the emails:send Artisan command will be run every minute if it is not already running.
Run Schedule Command for a test To check if schedule commands have been constructed successfully, run this command. After that, go to the logs folder inside the storage directory, open the Laravel. php cron job file, and check it. Note: You can use this command when you want a Laravel scheduler without a cron job.
To execute php artisan serve stop simply goto your commnad line where your server is running and press ctrl+c. It will stop your server.
Now to activate the scheduled jobs, run the Cron command. Go to your application from the Applications tab, and then to the Cron Jobs Manager. When done, make sure to save changes. That's it!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With