Hi
I'm trying to create a cron job to run a script at midnight every night, however I've not been able to successfully get it to run.
So I tried running the script in shell by doing the following:
/usr/bin/php /usr/local/home/httpd/docs/affcheck/dcm/grab.php
The output is...
X-powered-By: PHP/4.0.6
Content-type: text/html
<br>
<b>Fatel error</b>: Failed opening required 'TimeZone.php' (include_path='.:/opt/php-4.0.6/lib/php') in <b>/usr/local/home/httpd/docs/affcheck/dcm/Classes/Date/Date.php</b> on line <b>25</b><br>
The script TimeZone.php is in the same dir as the Date.php script and is called like this:
require_once 'TimeZone.php';
The Date.php script is called from the grab.php (i.e the script that is cron'd) like this:
include "./Classes/Date/Date.php";
Also the script runs fine in the browser with no errors.
* I checked /usr/bin/php was the correct dir by running which php in shell
Any help would be great.
Also this is my first cron job and I'm not great with *nix either, so simple is good :-)
You can't redirect output via > or >> because wget fetches the file not to stdout, but to the file (in this case 'grab.php'), by default. The only things that can be redirected is wget info about how it fared, but that is moved to quiet mode via the -q option already.
So, if you omit -O /dev/null, you would end up with a grab.php file in your directory. In addition, wget does not overwrite existing files, so you'd have files like: grab.php, grab.php.1, grab.php.2 ... one more after each run.
2. you do not add user to cron entry, because cron jobs are separate for each user.
if you are a root, you can edit other users' cron jobs, but else everybody is restricted to their own.
see "man crontab" for cron entry format (scroll down a bit), here is a quote from there:
# all the entries run the comand "date":
# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
# at 6:10 a.m. every day
10 6 * * * date
# every two hours at the top of the hour
0 */2 * * * date
# every two hours from 11p.m. to 7a.m., and at 8a.m.
0 23-7/2,8 * * * date
# at 11:00 a.m. on the 4th and on every mon, tue, wed
0 11 4 * mon-wed date