Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Sorry, I don't know anything about cpanel, but it sounds like:

  • if you created the file daily.php, then you need to change the permissions on it
  • if they created the file, then there's a bug in their creation routine.

Good luck!

try this one

/usr/bin/php -q /home/yourCpanelUsername/public_html/filename.php

for some cpanels it might be like this

/usr/local/bin/php -q /home/yourCpanelUsername/public_html/filename.php

Sounds like you need to make /home/abbeysof/public_html/adi/cron/daily.php executable.

The link might help you. https://www.inmotionhosting.com/support/edu/cpanel/how-to-run-a-cron-job

There is difference if you are using VPS than sharing hosting for giving the command. You may need to use user-agent & cPanel-Cron along with your url. curl --user-agent cPanel-Cron http://example.com/cron.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top