简体   繁体   中英

How to run a php script using cron

I have a php script that grabs links from another website. I am storing these links in my local system database using wamp server but my internet speed is so slow. I have to refresh the php script in browser after every 10 records.

So, can I run this PHP script on my webhosting server continuously for 24 hours and store all the links same as my local system. If it is possible then please help me.

Type in crontab -e in the/a terminal or through PuTTy on your server, enter something to the like of the code below, where m is minutes, h is hours, dom is days of the month, etc etc etc

# m   h       dom     mon     dow     command
*/5   *       *       *       *       php -f /directory/to/file/filename.php

This will run it every five minutes.

If you want to run it continuously (which it doesn't really do), it needs to be run piece wise, something like this would work, which would run it from 9.30-17.30 every day.

30-59/5 9 * * * script.sh
*/5 10-16 * * * script.sh
0-30/5 17 * * * script.sh

Here are the basics of cron, I suggest you read them.

Cron and Crontab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM