简体   繁体   中英

How to batch process a PHP script that takes a long time to execute?

I've built a PHP script that creates/restores a backup containing a sites content and database. It works really well on smaller sites but it runs into trouble on larger sites. What would be the best way to batch a script like this? Basically, it copies files from one directory to another, creates a DB dump and then zips the directory.

I've done a little bit of research, do I need to use cron jobs?

If it is something that happens at a fixed time / schedule, then it should be a cron job. This is fairly straightforward to set up. There are plenty of tutorials.

If, on the other hand, it is an action a user triggers from a web browser, you should fork and exec . You take in the user's input, fork and exec and then let the user know that he will be emailed when the process is complete.

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