0
I hired a shared server, which performs scheduled tasks (CRON TABLE
) via linux scripts (.sh).
How to run a command php Artisan (php artisan enviar:emaildiario
) within that linux script?
UOL server:
Script:
0
I hired a shared server, which performs scheduled tasks (CRON TABLE
) via linux scripts (.sh).
How to run a command php Artisan (php artisan enviar:emaildiario
) within that linux script?
UOL server:
Script:
0
There are several ways you can do this, but I’ll explain the two simplest:
Alternative 1:
Create a php page on your server, example http://your domain/crontab.php put the commands you want to run inside this php script. Create a tassel in your crontab to char that url at the time set by vc.
* */1 * * * root wget -q --spider http://<seudominio|localhost>/crontab.php >/dev/null 2>&1
Alternative 2:
Create a crontab task with the following syntax:
* */1 * * * root /usr/sbin/php /caminho/completo/do/script.php
See more in https://linux.die.net/man/5/crontab
Obs:
For security reasons change the user who will run the script.
Make sure that the user who will run the script has the due execution permissions.
Be happy!!!
Browser other questions tagged laravel linux shell-script cron artisan
You are not signed in. Login or sign up in order to post.
Probably inside the . sh something like
cd /pasta/projeto
and in the next linephp artisan enviar:emaildiario
– Guilherme Nascimento
@Guilhermenascimento my script . sh is already inside the root folder, so I thought it should just be php send:emaildiario, but it didn’t work
– Ademilson Santana da Silva
@Virgilionovic I just need to run the Artisan command inside a script . sh, I don’t need to do this cron structure inside the Laravel
– Ademilson Santana da Silva
@Virgilionovic Yes, this is already done, the command is already working on another server. The problem is that on this server that I’ve got now, CRON is done via scripts. Everything is already configured, all that remains is to understand the script and run Artisan
– Ademilson Santana da Silva
@Ademilsonsantanadasilva if you run . sh from another location, even if it is in the project folder, it will not work if you use the
cd
and point to the project as I explained should solve.– Guilherme Nascimento
UOL server. I edited the question with the images
– Ademilson Santana da Silva
https://uolhost.uol.com.br/faq/hosting/a-hosts
– novic
a pertinent observation if you are using Laravel that
.sh
has to return folder, because Laravel starts in folderpublic
and theartisan
is in the main folder ... this must be the problem encountered by you– novic