简体   繁体   中英

How can I run a php script on a remote server?

I have a remote Apache/2.2.16 (Debian) Server where I want to do intervalled jobs like every 2 hours do this, at 12.00 do this. So, I wrote a php file which can do this but I have to start it via the browser and have to keep the browser window open to keep the script running. I heard I could execute a php script via console, but I don't have access to it.

How can I run the script without access to the console and without having my browser opened?

Set up a cron job for this task. You can set this up on the server or on any other computer that runs at the given time.

On a Linux or Mac OS machine, open a terminal and type crontab -e .

Add something like this to the end of the file:

0 12 * * * wget http://url.com/your/script.php -O /dev/null

This will call the script every day at 12:00. Make sure wget is installed.

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