Page 1 of 1

PHP & Crontab - Execute a file at a certain time daily

Posted: Fri Oct 31, 2008 5:26 am
by mark.disney
Has anyone ever used the Crontab on plesk version 7.5.4 to excecute a .php at set intervals?

I know this isnt quite a .php question, so I have also posted this question in the general topic area of this forum.

I am trying to execute a file every day at a certain time. I have a linux server and use the Crontab program on the plesk control panel. I have created my scheduled task, I have set the time and the command line looks like this:

lynx -dump http://www.mywebsite.com/repeat/repeat.php

I get the following error:

Looking up http://www.mywebsite.com
Making HTTP connection to http://www.mywebsite.com
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://www.mywebsite.com/repeat/repeat.php

Any responses will be much appreciated.

Thanks

Mark

Re: PHP & Crontab - Execute a file at a certain time daily

Posted: Fri Oct 31, 2008 5:45 am
by Kadanis
When calling php scripts from cron I always have success with the CGI rather than calling the page in lynx.

Our servers are CentOS (RHEL) based so the locations might be slightly different

Here is the command for crontab

Code: Select all

 
/usr/bin/php-cgi -q /path/to/file.php
 
Then just schedule the cron job.

Re: PHP & Crontab - Execute a file at a certain time daily

Posted: Fri Oct 31, 2008 6:37 am
by mark.disney
I cant seem to find the /usr/bin/php-cgi -q, i keep getting the error "No such file or directory".

I manage to get the following working without showing any errors, except now it doesnt process my php in my repeat.php file?

lynx -dump /var/www/vhosts/mywebsite.com/httpdocs/repeat/repeat.php

Any suggestions?

Thanks