File path for a Cron Job
Asked Answered
T

5

7

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?

Terrier answered 29/6, 2010 at 20:50 Comment(0)
S
20

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.

Standstill answered 10/7, 2010 at 19:39 Comment(3)
You explanation just saved my day:) Thank you!Adena
wget creates temporary files. Check this #11375760Titoism
@Titoism you simnply need to use the -O - option to redirect STD_OUTPUT and STD_ERROR to blackhole "/dev/null" I updated the code of the questionStandstill
A
2

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!

Apostle answered 29/6, 2010 at 20:58 Comment(0)
D
2

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
Datura answered 26/10, 2013 at 11:32 Comment(0)
P
1

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

Piranha answered 29/6, 2010 at 21:24 Comment(0)
S
0

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

Skimp answered 11/2, 2018 at 14:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.