Artisan Laravel linux script

Asked

Viewed 176 times

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:

inserir a descrição da imagem aqui

Script:

inserir a descrição da imagem aqui

  • Probably inside the . sh something like cd /pasta/projeto and in the next line php artisan enviar:emaildiario

  • @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

  • @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

  • @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

  • @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.

  • UOL server. I edited the question with the images

  • https://uolhost.uol.com.br/faq/hosting/a-hosts

  • a pertinent observation if you are using Laravel that .sh has to return folder, because Laravel starts in folder public and the artisan is in the main folder ... this must be the problem encountered by you

Show 3 more comments

1 answer

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

You are not signed in. Login or sign up in order to post.