File path for a Cron Job

Mick picture Mick · Jun 29, 2010 · Viewed 17.9k times · Source

Hi I want to run a cron job to call a PHP script on my server. I am using Cpanel from my web host and these are the options:

  • Minute:
  • Hour:
  • Day:
  • Month:
  • Weekday:
  • Command:

I am really struggling to point the command to my file I am using this line /home/abbeysof/public_html/adi/cron/daily.php but I am getting this error:

/bin/sh: /home/abbeysof/public_html/adi/cron/daily.php: Permission denied

I asked my web host for help and this is the response:

If you use cpanel to create it, it will fill in the path for you. Typically /home/username/public_html/etc

Can anyone please offer some advice?

Answer

Marco Demaio picture Marco Demaio · Jul 10, 2010

Advise 1: use wget command, wget runs the PHP script exactly as if it was called from the web so the PHP environment is exactly the same of when calling the file from the web, it's easier to debug your script then.

wget -O - http://yourdomain.com/adi/cron/daily.php >/dev/null 2>&1

The cron jobs has to be created going into cPanel cron jobs menu. I don't understand if you have this clear by reading your hoster's answer.

And advise 2: change web hosting, try this one they don't leave you alone.