Hi guys,
I am having an issue with a cron job I setup. It runs a php file. The php file runs fine if I execute it through a browser.
In the php file I reference a .txt file held on the server. I do a file_exists and check for existence. When I run this through the cron it can't find the file however when I run through the browser it finds it and works fine.
Any ideas on how I should reference the path to the file (i assume this is the issue).
Cheers,
J
PHP and Cron Jobs
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: PHP and Cron Jobs
In your cron configuration, instead of running this:
run this:
The issue is the relative path. It's being referenced from the wrong place.
Code: Select all
$ php /path/to/my/php/file.phpCode: Select all
$ cd /path/to/my/php
$ php file.phpRe: PHP and Cron Jobs
Problem is it's though a hosted webserver and I can't really run much in the way of cron commands. They only have a single line for command.