简体   繁体   中英

cron jobs fails run php script sometimes

I am using php file_get_contents function to get some data from other websites.Also i use cron jobs to run that script automatically.The cronjobs works fine but sometimes fails to run. this is my command in cron jobs (in cpanel):

*/10 * * * * /usr/bin/php -q public_html/include/imp.php > /dev/null 2>&1

this command should repeat every 10 minutes.but not work sometimes even for 48 hours. it's ok when i run that php script manually.

thank you.

I had a similar issue, the script ran fine when the URL was visited directly, and would run sometimes, seemingly randomly. Turns out it was host server resource issue. Hostgator wont run a cron job when I'm connected via SSH with Putty on 2 computers.

From their help pages "SSH access is limited to two simultaneous connections on Shared and Reseller plans. Note: Any cron jobs configured will require one of these sessions to be available in order to run, since cron jobs run under the same shell as SSH."

When I close the SSH connection, the cron job immediately runs.

Maybe your host has a similar rule?

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