4

I am trying to setup a CRON job using PHP, but am not having any luck so far.

I am following this tutorial: PHP - Create a Cron Job with PHP (dead link)

I have created the script file with the correct permissions, but the script is not being processed.

Any ideas?

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
  • 1
    What does your crontab look like? Is the exec() call executed correctly? What does crontab -l show? – kb. Feb 15 '10 at 08:47
  • This is the exec command I am running exec("crontab {$_SERVER['VIRTUAL_DOCUMENT_ROOT']}cron/cronfile > {$_SERVER['VIRTUAL_DOCUMENT_ROOT']}log.txt", $output); crontab -l dosen't show anything. Cron is running on the server. I don't have access the command line so I can't test the script. – account holder Feb 15 '10 at 09:31
  • Thanks for your help everyone, I have talekd to my host again and they have given me the required permission to carry out this proccess. – account holder Feb 16 '10 at 09:29

3 Answers3

1

Maybe your cron daemon isn't running? The daemon "crond" have to run on startup.

Check this with "ps -efc |grep crond"

u2ix
  • 592
  • 1
  • 5
  • 12
1

Little checklist:

  1. Is your cron running -> u2ix [checked]
  2. Permissions to use cron [checked]
  3. Does your script run in the shell [checked i hope]
  4. Run a litte script that shows you the environmet in your cron (-> env) / it is never the same as in your shell :-)
  5. after execute your php-creat-cronjob-script check with corntab -l the crontab

-- do you get mail from your cron ?

Blauohr
  • 5,985
  • 2
  • 25
  • 31
0

it seems you could have any number of issues here.

Firstly have you checked that the file runs successfully from the command line?

if so another simple solution to the problem could be if you didn't set the file to be added correctly in $command so this could be pointing to a file you don't have.

Also checking that to cron file you have specified matches the directory referenced in these lines:

    // this will reinstate your Cron job

    exec("crontab /Users/vin/Sites/site/cron/Feed_cron"); 
Philderbeast
  • 71
  • 2
  • 7