doutan8506 2015-11-25 06:32
浏览 27
已采纳

工匠cron工作产生许多过程

I use aritsan command(lavaral 5.1) deal background job,

I set * * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1 in crontab accordance with the mamul.

and my job setting like

'$schedule->command('job')->cron('0 * * * *');' 

in Kernel.php

This task works well, but when I check my server process a few hours later, I find aritsan generate many process,

Note: In my job, I write exit() after program end in handle() method. please help me find that why artisan generate those progcess(not exit?), it occupy many memory.

Thanks very much!

~ ps -aux|grep artisan|grep -v grep|wc -l  
24  

root     15690  0.0  2.3 235588 11872 ?        S    Nov16   0:05 /usr/local/bin/php artisan job  
root     16382  0.0  2.3 237748 11996 ?        S    Nov16   0:06 /usr/local/bin/php artisan job  
root     17735  0.0  2.3 237748 12036 ?        S    Nov16   0:05 /usr/local/bin/php artisan job  
root     17786  0.0  2.4 237748 12052 ?        S    Nov14   0:15 /usr/local/bin/php artisan job  
root     20274  0.0  2.4 237748 12056 ?        S    Nov14   0:14 /usr/local/bin/php artisan job  
root     23771  0.0  2.4 237748 12056 ?        S    Nov14   0:12 /usr/local/bin/php artisan job  
root     24191  0.0  2.4 237748 12056 ?        S    Nov16   0:03 /usr/local/bin/php artisan job  
root     26192  0.0  2.4 237748 12048 ?        S    Nov16   0:02 /usr/local/bin/php artisan job  
root     26287  0.0  2.4 237748 12048 ?        S    Nov14   0:12 /usr/local/bin/php artisan job  
....  
  • 写回答

1条回答 默认 最新

  • dongwei3866 2015-11-25 08:25
    关注

    You should try executing the scheduled tasks manually with

    php /path/to/artisan schedule:run
    

    and see how much time it takes to run.If this takes a lot of time it means that you have a bottleneck somewhere and it never reaches your exit(). You might have a racing condition in there with more than one processes requesting for the same thing.You would need to find the time consuming task and try to optimize it.Also you might want to use

    ->withoutOverlapping();
    

    so that no more than one task is running simultaneously.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛