Cron job error "could not open input file"


#1

I have a cron job trying to run a PHP script:

/usr/local/bin/php /home/mydirectory/path/to/myfile.php
(the path is not the actual path)

this is the error I get
Could not open input file: /home/mydirectory/path/to/myfile.php

When I run this as a shell command the script runs fine (using exactly the same command)
Permissions are 755 for the file.

I have the “#!/usr/local/bin/php -q” at the top of the file. but I get the same error whether it is there or not.

i am adding the cron job through the web panel.

What am I missing here?


#2

In theory, your method should work, but try something like this anyway:


#3

Are you sure you’re running cron as the user that owns the file?

Is there any more part of the error? I often see that error because myfile.php is trying to read from some other input file that’s causing the problem.


#4

I was wondering the same thing. Making a script like the one mentioned in my post above should solve that problem. If that is indeed the cause.


#5

Thanks guys for your quick replies. I’m almost too embarrassed to say what the problem was, but for the sake of future idiots like myself…

If you log in to dreamhost and are party to multiple accounts, make sure you are in the right account.
Cause if your not in the right account, it’s not going to find the file.
Duh :slight_smile:

sdayman, your question of are you sure i’m running cron as the right user was right on the money!

Working now.

(for the record, since you both asked: the error files did not say anything more than no input file found and the path.)

Thanks again,
Adrian


#6

I’ve been having this error for over a week now with my cron jobs.

Right now I’m not able to make a user for my cron job, so I think I have the same error you had where my users didn’t have access to either server to run the cron jobs.

Do you know how to give access to the cron jobs for my other user accounts? I had created a shell user that doesn’t have access to the other servers.