Ad

Is There A Way To Check If Laravel Schedule Is Running?

- 1 answer

I am maintaining many copies of one application (built on Laravel) on different hosts, and I am looking for a way to check if Laravel Schedule is actually running for each. Does Laravel offer something for that?

Ad

Answer

No, there is nothing built into the framework that will tell you which hosts are running schedule:run. You will have to implement that yourself.

If you have a central system tracking the hosts, then you can make a command which sends a heartbeat ping to your central system, and add that command to the scheduler.

If you have some logic that depends on knowing whether its current host is running a scheduler, then you can make a scheduled command which writes the current time to a file on the local disk (writing to the cache also works if it's not shared between hosts, or the key is unique to the host). Then you simply check whether ($now - $last_write) > $schedule_interval is true.

Ad
source: stackoverflow.com
Ad