PHP Cron Job

Status
Not open for further replies.

hellblazer

New member
Sep 20, 2008
3,020
86
0
I'm trying to run automate.php and this is the command I'm running:

"php /home/my_user_name/public_html/blog/wp-content/plugins/plugin/automate.php"

I've tried calling the URL, tried it without home and username, but this piece of shit is not going. Any ideas?
 


11 3 * * * wget http://www.domain.com/blog/wp-content/plugins/plugin/automate.php

that'll run the automate.php program at 3:11 am server time every day

What he said. Basically without actually scheduling an actual cron job, the php script will only invoke when someone calls for it. Any attempt to do a infinite loop will normally cause the host to reset the server, or PHP to kill it after the time limit (5mins? depends).

So as erect said, you have to actually call the script via wget in the cron tasks in order for it to work. You can't do what you want to do strictly with PHP and nothing else.
 
What he said. Basically without actually scheduling an actual cron job, the php script will only invoke when someone calls for it. Any attempt to do a infinite loop will normally cause the host to reset the server, or PHP to kill it after the time limit (5mins? depends).

So as erect said, you have to actually call the script via wget in the cron tasks in order for it to work. You can't do what you want to do strictly with PHP and nothing else.

No, I was calling the command from the Standard interface in Cpanel. For testing purposes, I had it scheduled to run every minute so I could see if it works. But that wget command worked awesome. Thanks erect! +rep
 
No, I was calling the command from the Standard interface in Cpanel. For testing purposes, I had it scheduled to run every minute so I could see if it works. But that wget command worked awesome. Thanks erect! +rep

I guess your hosting wasn't setup to call the php interpreter as a binary itself, but rather only setup as an apache module. (otherwise it would have worked.)

Course while the wget method works, the script being in a web-accessible location could be an issue if someone hammering it would be problematic to you.
 
I guess your hosting wasn't setup to call the php interpreter as a binary itself, but rather only setup as an apache module. (otherwise it would have worked.)

Course while the wget method works, the script being in a web-accessible location could be an issue if someone hammering it would be problematic to you.

Yeah, you could be right about the hosting. I ran a ton of php commands and kept alternating the path and url, but no dice. wget worked the first time, though so it's sweet.

Someone hammering it? I'm not sure what that means - they couldn't actually edit the automate.php file, could they?

Are you saying there's some other way to run the cron job that's more secure, kblessinggr?
 
Yeah, you could be right about the hosting. I ran a ton of php commands and kept alternating the path and url, but no dice. wget worked the first time, though so it's sweet.

Someone hammering it? I'm not sure what that means - they couldn't actually edit the automate.php file, could they?

No, but if the URL is accessible to the rest of the world, someone could try to call the automate.php script like several hundred times a minute. And if the script does anything cpu intensive this could put a serious crimp on your site's performance.

Are you saying there's some other way to run the cron job that's more secure, kblessinggr?

If you wanted to continue to use the wget method, I would at the very least pass something to the script, like for example ?tempcode=yadayada and if it doesn't get the tempcode to simpley exit(); otherwise perform the job as intended. This way even if someone does know where your automate script is, they won't try to do something like a DDOS attack and hammer the shit out of it. Mainly only effective if your automate script does anything heavier than what your site normally would do. :D. But just something to think about.

Otherwise you could instead write a perl script to do the same job, which is more easily called from the system and isolated from the web. (course requires some perl/cgi knowledge)
 
Status
Not open for further replies.