Page 1 of 1

Laravel Task Scheduler Issues

Posted: Sat Apr 07, 2018 7:20 pm
by tahirafridi
Dear members,

I'm using Laravel from last few months and today I have tried their task scheduler which is found here > https://laravel.com/docs/5.5/scheduling

From their document I have found this command to insert into my vestacp command input box
* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

I have modified the path like this
* * * * * php /home/admin/web/example.com/server_files/artisan schedule:run >> /dev/null 2>&1

But its not working and I'm not getting any email notification like I was getting notifications in CPanel.
I can see there is a option in vestacp that you can turn ON or OFF the notifications, but mine is ON but still can't see any errors etc in my email or somewhere else.

Please if anyone has some tutorial about to setup laravels cron job then please help me out. I know how to create cron job via wget https://example.com/yourfile.php

But I need the cron job like laravel has mentioned in their document and I'm not sure how to modify the code so vestacp can run my command.

Note: Further information can be provided if needed from someone.

Regards
Tahir Afridi

Re: Laravel Task Scheduler Issues

Posted: Sun Apr 08, 2018 9:01 am
by grenadecx
HI there,

I'm running multiple laravel installations with task schedulars without problems. Have you tried running the command manually to see if it works?

You can also check the /var/log/syslog, it should have traces of attempting to run the schedular. Like:

Code: Select all

Apr  8 10:59:01 web01 CRON[29418]: (****) CMD (php /home/****/web/****/public_html/artisan schedule:run >> /dev/null 2>&1)
Here's how my cron is setup from within vestacp
Image

Re: Laravel Task Scheduler Issues

Posted: Sun Apr 08, 2018 10:44 am
by tahirafridi
Hello grenadecx,

Thanks for your kind reply, and I appreciate your reply. Yes I have the exactly same thing in my command input box, and yes I have checked my created command from php artisan in my cmd and its working and my function is running fine there.

The thing is that how do I know what is the issue and why its not running from live server, you have mentioned the area where I can see the log, but please give me the details how to access that particular location from filezilla or using filemanager, or may be from SSH putty.exe file.

For now I have created a route and in that route I have executed the command that I have created from php artisan, and I have put wget https://example.com/controller/method and its working, but what I'm missing the laravel scheduler, because I have to set the cron once, if in future I have more crons to run, then I don't need to put those into live server, I can just put it in to the kernel.php file and thats it.

Once again thanks for your reply and I appreciate your efforts. Atleast i have got an idea that I have done the command correctly same like yours, but need to worry how to get the notifications, and if its not possible to get notified then why the hell they have put that button to make us fool. Vestacp should remove this button that saying turn on notify or turn off notify.

Regards
Tahir Afridi

Re: Laravel Task Scheduler Issues

Posted: Sun Apr 08, 2018 10:48 am
by tahirafridi
Further more I have created a folder out side of public_html and I named it server_files and I putted all my files into this folder except the folder public,
I extracted all the public files into public_html and in index.php file I have put the path to that server_files folder, so my artisan file is in server_files folder, so in your command you have public_html/artisan but in mine its server_files/artisan

I don't think its an issue, but may be you can help me if you can check this issue.

Re: Laravel Task Scheduler Issues

Posted: Sun Apr 08, 2018 10:56 pm
by grenadecx
It almost sounds like the cronjob isn't running at all. If you ssh to the server, you can access the syslog file with the following command:

(this will open it in a text editor, and then you can scroll the configuration file to look for clues).

Code: Select all

nano /var/log/syslog 
In regards to the location of the public_html / server folder, I have a laravel (nginx) configuration that points the public folder to public_html/public. But it doesn't matter. Running artisan doesn't care about where the public folder is located. So you don't have to worry about it. Besides, the way you do it is quite common when moving laravel over to a shared hosting provider.

If it works running it manually and it works from a controller, which isn't optimal due to http timeout issues, then the next step has to be checking if the server even runs the command from the logs. So check the syslog file and then we can take it from there.

Another thing you could do as well, after you have logged into the server with ssh, if you gain root privileges (run the command: sudo -i), then you could run the following command to see if the webinterface have registered the cronjob.

(replace insert_user_here with the vestacp user that is running the cronjob)

Code: Select all

crontab -e  -u insert_user_here
The command above will open up the cronjobs for that particular user into a nano or vim (text editor window) and you should see the same cronjob as you inserted from the webinterface, including the notification stuffs.