Cron Path

I’m trying to run a script that includes a select query and then an update query on some records in my database. I tested it manually by visiting it in my browser and it worked fine.

I need it to run periodically and so I set up a cron job with cpanel. Initially I got emails stating that I failed to set the php interpreter. So I fixed that and then stopped getting emails and there is no sign that the program is running as scheduled.

In my command line I have “/usr/bin/php -m /home/myname/cron/file.php”

I’ve also used -f and -q and used different locations for the file, including putting it into public_html.

In the first line of file.php I have written “#!/usr/local/bin/php”

permissions are either 777 or 755 on file and the paths to file.

There is no email and no indication that the file is running still. I must be missing something–the host said the cron functions are all working properly.

Does the script rely on any of the $_SERVER variables to configure its self? They won’t be present when the script is not executed by the web server.

You might need to build a $debug string (noting steps of the script as they are executed) and write it to the file system so you can see what the script is actually doing.

The script does not rely on any $_SERVER variables. It runs one select and one update mysql query (I reiterate, just in case, cause I’m new to cron commands.)

I’ll consider a debug string.

I tried changing the email address for the emails and I got a bunch of old emails. But no reports for days.

Try this as the command:

cd /home/myname/cron/; /usr/bin/php -m file.php

One of our FAQ articles goes over some of the variances that some servers need:

While the article is written for our product, the concepts are universal.


Is it possible that my attempting of multiple cron commands can damage or alter the cron system on my server?

Multiple cron jobs won’t be a problem.

Ok, what if I were to write a cron command that were “bad” (sorry for the vague term)–would this cause any damage to the server? My host is giving me issues about this, refusing to take action to look into the no-email problem.

The hosting provider isn’t likely going to help since the issue isn’t with the cron job, but something to do with the script or how the script is being executed.

An incorrectly entered cron job won’t break the server unless what is being executed is poorly written and loops endlessly.

Are you able to log into the server via SSH and execute the script from the command line? If so, does it send the email then? If it does send email, or behaves as you expect, then the cron job should work when correctly set. Also, what happens when you try to run the script from the browser?

Well, the emails did run just fine to tell me the php wasn’t being interpreted. That was when I accidentally ran the command without the php interpreter and then I added it. The server was down for a short time and when it returned I could not get emails. I tried to get emails for an incorrectly entered command (like the very first one I made with the mistake) to see if that would do anything, but received no emails then, either.

I have tested the script from the browser–it works just fine that way.

The host did not readily share the path to php–I had to request it in a support ticket and then when I entered it, I had no indication that the script was running and no email of any kind.

I also do no have shell access (though they insist I do, from my cpanel. I realize this makes me sound very incompetent, but I am not. The shell access, in my past experiences with cpanel, has an access option under the “security” header as a dark icon. This one does not have it. I looked around for a different icon or title or anything referring to shell but it wasn’t there, either. Frustrating.)

Final question: What does the “-m” parameter mean?

As for how this issue was settled: I tested the script and the cron command with a different host and it worked; the host continued to refuse to look into why it was not working. So I changed hosting companies and everyone works just fine.

Thanks all!

using the -m flag in the command would prevent your script from being executed.

You are absolutely correct and feel rather dumb for not catching that earlier.:confused: