Hi,
My web site use PHP and MySQL and it is on UNIX server.
How can I schedule one PHP script to run every day ? This script delete
some records of MySQL database.
1. I tried to use AT command from UNIX system - without any success.
2. I created stored procedure on MySQL server, but I dont know how
I can schedule it.
Please help me !
Schedule running of PHP script daily
Moderator: General Moderators
Re: Schedule running of PHP script daily
If you have a fully dedicated server (as in you have root access and you are the only user on the server) you can use cron jobs to do the cleanup. Unfortunatly I'm out of practice to give any examples, but looking at the cron manual you should be able to figure it out. If memory servers, it is just a matter of picking when you want it to run, hourly, daily, monthly, everytime you boot, etc, and then adding the command to one of the cron files. At the command prompt, type "man cron" and that will bring up the manual for the cron daemon.
Now if you don't have root access, and/or are not the only person on the server there is a way to do it, but it is one of my classic "Way too much work to get the job done" methods. Also known as "The dumbest way to do it" method. This would be to create an html page that refreshes itself every hour, or whatever, and in the php code for the page it checks the current time agaisnt the schduled time for clean-up. If it matches it executes the clean-up. You would need to keep a web browser open with that page on it 24/7. Another cheap way would be to create the page, but without the refresh tag, then run some sort of program on your computer to open the page at a certain time. You could use php and/or .htaccess to restrict access of that page to your IP address only.
Good luck.
-seg
Now if you don't have root access, and/or are not the only person on the server there is a way to do it, but it is one of my classic "Way too much work to get the job done" methods. Also known as "The dumbest way to do it" method. This would be to create an html page that refreshes itself every hour, or whatever, and in the php code for the page it checks the current time agaisnt the schduled time for clean-up. If it matches it executes the clean-up. You would need to keep a web browser open with that page on it 24/7. Another cheap way would be to create the page, but without the refresh tag, then run some sort of program on your computer to open the page at a certain time. You could use php and/or .htaccess to restrict access of that page to your IP address only.
Good luck.
-seg
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK