Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File path for a Cron Job

Tags:

cron

cpanel

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?

like image 732
Mick Avatar asked Jun 29 '10 20:06

Mick


4 Answers

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.

like image 75
Marco Demaio Avatar answered Nov 12 '22 06:11

Marco Demaio


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!

like image 21
Michael H. Avatar answered Nov 12 '22 07:11

Michael H.


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
like image 35
Mahendra Jella Avatar answered Nov 12 '22 08:11

Mahendra Jella


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

like image 39
Douglas Leeder Avatar answered Nov 12 '22 06:11

Douglas Leeder