How to create commands for shots through a CRON task

Asked

Viewed 119 times

0

I don’t have access to Cpanel Linux and have been asked to submit the command script to the responsible person. I also don’t have much knowledge on cron tasks and would like to know how I can create one to send a daily charge shot to users. I thought about using it that way, but I don’t know if it’s right:

0   0   *   *   *   
curl -s -o /dev/null http://site.com.br/disparar-cobranca/index.php

Could you help me so that I can send the correct command? The server is from Locaweb and the PHP version is 5.2.17.

1 answer

2


The title of the question does not suggest the same as the content of the question.

In my interpretation you need to "test" your script to see if it’s functional. So let’s go!

Yes, the script is FUNCTIONAL. But there’s one small question[little].

When you call the curl parameter -s, it does not generate output.

When you call the curl parameter -o, it stores the output in such file.

So to fix your script (despite being functional), just call the curl with the parameter -s and the path of requisition:

curl -s http://site.com.br/disparar-cobranca/index.php

Another thing: If you’re requesting this from a company, it obviously has access to shell server. Then, it would be more appropriate to call your script straight with the PHP. Just knowing the way PHP on the server, which would eventually be on account of who will install your cronjob. Usually stays in /usr/local/bin/php. Hence its cronjob would look like this:

0 0 * * * /usr/local/bin/php /caminho/do/site/no/servidor/index.php

PS: /caminho/do/site/no/servidor/index.php should be changed according to the path of your site, as already made explicit. Usually it is in /var/www/html.

If the purpose of your cronjob is to rotate this php script every day at midnight (midnight), will work right.

  • Hello @Lipespry. Perfect. Thank you very much for the clarifications.

Browser other questions tagged

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