Schedule page loading through CRON

Asked

Viewed 1,029 times

2

I have a page in PHP that checks the news feed of some blogs and records the records in the database.

For this to happen, it is only necessary to load the address ex: "www.site.com/pagina.php", I would like to automate this somehow, to run once a day.

I tried using the CRON from my Cpanel, but I don’t know which command I can use. If you have another way to do this, you are also welcome.

2 answers

4


Better run crontab directly on the server. crontab has the following format:

[minutos] [horas] [dias do mês] [mês] [dias da semana] [usuário] [comando]

The completion of each field is done as follows:

  • Minutes: enter numbers from 0 to 59;

  • Hours: enter numbers from 0 to 23;

  • Days of the month: enter numbers from 0 to 31;

  • Month: enter numbers from 1 to 12;

  • Days of the week: report numbers from 0 to 7;

  • User: is the user who will execute the command (it is not necessary to specify it if the user’s own file is used);

  • Command: the task that must be executed.

To run "my-script.php" every 1 hour do the following:

# crontab -e
00 * * * * /usr/local/bin/php /home/pedrodelfino/meu-script.php

Other examples can be found at the following URL http://pt.wikipedia.org/wiki/Crontab just leave a hint, the path to the PHP file should be absolute, so everything will work fine.

  • this is for linux? Or it doesn’t depend on the OS. I saw a similar example that was for linux.

  • Yes André, it’s for Linux.

  • How do I run a @Renatotavares URL? Instead of a specific file?

  • @Andrébaill cron runs a command, you can give a wget in the url you want or create a shell script that makes a Curl or wget in the url you want and calls this script in cron.

0

Go to cPanel. Select the period and put it in the command:

php /home/diretorio/ate/arquivo.php

Browser other questions tagged

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