Little help with simple Cron Job

Hi, I was looking for a little help with a simple cron job that will just run a simple php page every hour.

I took a look through this forum and found some discussions but was unable to use the solutions mentioned.

I have gotten a cron to do this on a different hosting successully. I had a quick livechat with someone from dreamhost and they thought this may do it:

php -q -f /home/user/url/cron/cron.php

It won’t work and I get no email if I enter it. I have 2 users, both with webshell access and “enhanced security”. I have been selecting the user from the dropdown that matches the user in the script above. I have tried about 7 or 8 different scripts I have read on various forums with no luck.

This should be about the easiest thing a cron can do but it has me stumped. Any help would be greatly appreciated. Thanks.

I assume that you have tried to run this manually by simply pointing your browser to http://url/cron/cron.php What happens with that test? And is the email you are expecting only the cron generated email? or does the script itself send mail using mail(). The reason I ask these questions is that sometimes a dreamhost webserver has issues sending email… i.e. they have been RBL’d as mail senders. So one question to sort out is it’s really working for you but the email is getting blocked.

Second, using php -q -f /home/user/url/cron/cron.php is probably going to get php 5.2 I would use

/usr/local/php53/bin/php /home//path/to/script.php

More examples:

And third, if your script is generating the email using mail() then make 100% certain that the email is being sent FROM a valid email address at your domain. You can’t spoof the FROM address at dreamhost, and many ready made scripts (especially contact form variety scripts) attempt to do that.

LakeRat, thanks for your reply.

The email I was referring to is the email form the cron job itself that sends to the email you enter when setting it up.

The page, when run manually by visiting it in a browser, works as it should, but I can’t get the Cron to trigger it.

I believe I already tried the longer version of php, but I will try again and let you know.

If the email address you are specifying is outside dreamhost, try one at dreamhost. again the reason is dreamhost webservers can be RBL’d to the outside world.

LakeRat, I will try a dreamhost email for the output.

This: /usr/local/php53/bin/php /home//path/to/script.php

Still does not work. Any other suggestions?

What’s your webservers name? And whAt domain (the part after the @) was the email address you were using?

The email I have entered in the cron is now

Since changing the email it now sends an output message “Could not open input file: /home/gmisener/”

xxxxs are there to hide the full url which is irrelevant.

You got me a little further with the email help. Any ideas why that url can not be found? Thanks again.

sounds like you’re not translating your URL correctly.

So you said you can visit the url and the file runs, but for some reason when you try to call it /home/gmisener/ it’s not there. Remember that case counts /path/to/url.php and Path/To/URL.php are two different things.

the actual question i asked before about the webserver meant the name of the server your on (I was going to check it against email RBL’s) but it sounds like we got passed that point.

Yes, that is correct, when i view the in a browser it executes the php fine but /home/gmisener/ does not and I double-checked the case.

things that you can check:
1- file permissions - the php file should be 755 and all the folders above it (back up to directory) should be 644. Running the file via a browser/apache will use world permissions while when it runs from cron it will run as owner.
2- Navigate to manage domains in the panel, and find the line for – look at the webhosting column, is the user listed there gmisener? is that the user you are using on the first dropdown of the cron page in the panel?

LakeRat, the problem was the usernames. Turns out there were 2 usernames and I should have been using a different one. I used gmisener because it was the login for cpanel but it wasn’t the right one for crons.

All working now. I appreciate your help. Thanks.