Run a cron Cpanel URL

Asked

Viewed 4,820 times

-1

I need to run a URL at 19:00 every day. I tried using Cpanel’s cron job, but the url is not executed.

curl -s -o /dev/null http://minhaurl.com.br/index.php/sms/enviodiario

What would be wrong?

  • 1

    Tested without the cron, directly through the console? Another point, is, if the site is inside the server itself, it could run php directly, without needing the url or use of webserver (apache, etc)

  • So, I don’t know how it works without cron, and it’s inside the server yes, however, since it’s models, and controllers, I don’t know how I could run this file, I don’t want to make a separate file for connection, I wanted to run the url itself, which calls the right methods

  • the fact that having "models" and "Controls" does not affect anything.. rsrs.. there is the importance of a versatile system. Be able to request also via CLI (command line interface).. but if the system is not ready for CLI mode, there is no way.. or implements or does so anyway. This is another subject, but I found it interesting to comment

  • Here’s an example of how to use cron by calling a PHP if it’s on the same server. http://answall.com/a/124519/ - just change the path of the Artisan for your PHP. If it is on the same machine, it makes no sense to make an HTTP request (by the way, it usually ends up being a gambiarra, if you have nothing that requires a specific HTTP method, which your path in the question indicates). Even by calling PHP directly, you can perform longer tasks without timeout problems or competition with the web server.

  • about Curl, you have to make sure that Curl is available in your bash. You can try another tool like wget, for example.

  • 4

    Other posts on the same subject: http://answall.com/questions/112587/70 - http://answall.com/questions/38725/70

  • @Bacco Ok, but I could not adapt this to my reality... he executed according to the answer of our friend, however, did not give any result...

  • There is not much to adapt, just copy literally and put the path. If it does not work is problem in the code, and appears in the error log.

  • Yes, I understood perfectly, however, how the system is MVC, how I could perform the model?

  • 1

    Such a task should not be written as part of MVC, after all it is a maintenance routine, not even need normal user interaction. Regardless, the model itself should not affect anything, because PHP called from the command line is the same as the page server calls. Now, if you’re depending on routes or something like that, sign that it’s time to simplify the architecture.

  • It runs normally, however, does not do what was expected... arrives the normal return in the email.

  • % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 0 0 --:-:-- -:--:-- 0 100 300 100 300 0 0 19565 0 --:--:---:--:---:--:---:-- 292k

  • Specificities of the application is already more difficult to palpitate without knowing its code. Probably missing some silly detail only, remember to check your error log to see if everything is in order.

  • So @Bacco, if I run this URL, normal, in the browser, the function is called normally and brings me the expected result. I need to perform this function every day at 08 am

Show 9 more comments

1 answer

4


Try this on here

wget -O /dev/null http://minhaurl.com.br/index.php/sms/enviodiario

when I need to use I do this way, see and Curl is enabled on your server and if you want to use with Curl you do this order

curl http://minhaurl.com.br/index.php/sms/enviodiario -o /dev/null

I do not know if it influences but this is how I have been using in my server with Cpanel

  • How do I know the command was executed? Is there any feedback on Cpanel?

  • He ran normal, but it didn’t work out so well... :/

  • just take the /dev/null and configure the return email to your email, and in your url just vc print a reply or report that everything q is displayed on the screen goes to your email

  • I’m trying, but it didn’t work anyway... does not come back, and does not perform the function I need, but if I access via normal url, it works

  • Within your php code use the email sending function, so you will receive an email every time it runs.

Browser other questions tagged

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