dongqiao5573 2016-09-28 09:22
浏览 57

使用中断导入文件 - laravel

I have a laravel app. I use a cronjob which runs every 4 hours, and imports csv files and saves in the database.

I have limited times (300 sec max execution time, 60 sec cpu time). The import script should import a lot of csv files (400+).

Is there a way to interrupt before the time runs out and call the import script again? Or how could I solve this so the files can be imported safely?

  • 写回答

1条回答 默认 最新

  • dta43039 2016-09-28 13:50
    关注

    Probably the best solution if you want to guarantee the process is completed is to use non-overlapping task scheduling. You can read all about it in the documentation:

    https://laravel.com/docs/5.2/scheduling#preventing-task-overlaps

    It's in fact still a cronjob, but Laravel internally will make sure only one process runs at a time. As such you can still (for example) schedule it to run every minute, so that it immediately restarts after it ends or .. in your situation schedule it to run every 4 hours without the risk of restarting when the previous is not yet done.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用