简体   繁体   中英

Load php script to run with cron

First, apologize for my English.

I am creating a script for my web subscription. This script will run with a cron but I doubt emerges.

My host has a limit of 25 emails every 2 minutes, 200 emails per hour, and the php max_execution_time configuration is 120. The script should send 6 emails every minute. Because of this limutaciójn, I get the time it takes to run the script and do a sleep time to 1 minute remaining, so do not like to do is to reload the script with the new parameters sent using GET.

When a script run by cron, I can not use javascript or header location, so do not really know how to make this script will reload with the new parameters.

Does anyone have any idea, please?

You can use cron to launch your PHP script via either command-line or with a workaround as a standard web script. If you want the latter you can just wget http://localhost/whatever.php > /dev/null 2>&1 . Note the output redirection, because any output in processes lauched with cron will be mailed to the owner of the given crontab, so better suppress the output and log errors or notification separately.

Anyway, crontab allows for a one-minute interval between launches, so you shouldn't really have problems with your scripts timing out. Just make sure your script doesn't send more than 12-13 mails per launch (put a 5-second sleep between mail() calls) and you should do fine.

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