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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mark.disney
Forum Newbie
Posts: 7
Joined: Tue Oct 21, 2008 10:18 am

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

Post 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
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

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

Post 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.
mark.disney
Forum Newbie
Posts: 7
Joined: Tue Oct 21, 2008 10:18 am

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

Post 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
Post Reply