简体   繁体   中英

Cron php5 too many processes

I have a cron:

* * * * php5 /home/update_tunein.php
* * * * sleep 15; php5 /home/update_tunein.php
* * * * sleep 30; php5 /home/update_tunein.php
* * * * sleep 45; php5 /home/update_tunein.php

Every time cron makes a new proccess. These proccesses makes CPU usage 100%. How to make cron do only 1 proccess? Or maybe how to kill proccess after work?

... && killall php5

isn't working. Help me please

you have many entries and time of that entries overlapping .
you can do this way

   * * * * * ~/script.sh

put in script.sh file like below that will create 3 background process. for more info here

(sleep 15 && /path/to/task) &
(sleep 30 && /path/to/task) &
(sleep 45 && /path/to/task) &

EDIT : it is bad approach to use crontab for less then 1 min and also it not support less than 1 min directly . better then this you have to create you own script to run it . if your task take more than 15 sec than some wrong may happen.

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