zarax zarax - 29 days ago 15
PHP Question

Laravel runs scheduled commands without cron job

I have created some commands and scheduled them to work periodically. A few months later I noticed that there is no cron job running but commands run without problem.

In the documentation, it says that I need to set a cron job in the operating system for scheduled commands to run. I couldn't find any. But artisan

queue:listen
command is run as daemon. Could this command be running the scheduled jobs as well?

Laravel 5.1 on Ubuntu 14.04

Answer

Basically, when a cron job is created, the associated crontab file is generated for each user that ran the actual command. When this particular artisan cron was generated, it was created by the www-data user, which was why you couldn't find it as easily.

Each crontab is stored as /var/spool/cron/crontabs/<username>, and should be open to something like Grep, or other commands to inspect their contents.

Once you find the correct crontab that needs to be adjusted, you can change the file by running sudo crontab -e -u <username>.

Comments