PHP cronjob

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

PHP cronjob

Post by JKM »

How do I run a php script in cronjob (the php script contains only mysql queries)?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP cronjob

Post by pickle »

You'll have to put a shell command inside your crontab file. Usually that can be done by calling crontab -e as root. Alternatively, you can make your PHP file executable, and put it in the appropriate cron.daily, cron.hourly, etc directories (if your Linux distro has those directories).
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: PHP cronjob

Post by Eran »

If the queries are static, you can use the MySQL event scheduler instead - http://dev.mysql.com/doc/refman/5.1/en/events.html
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: PHP cronjob

Post by ldougherty »

If you do have access to cron tab then the following URL will prove useful as it will walk you through creating the cron job from start to finish

http://www.astahost.com/info.php/Cron-J ... t2324.html
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: PHP cronjob

Post by JKM »

Thanks, mate!
Post Reply