0

I would like to delete all the data from a specific MySQL table every day at 00:00. What is the best way to achieve that?

I was thinking of creating a simple PHP script that runs a mysql query every day at 00:00, I would then run the script using an online cronjob service..is this a good way to do it?

Thx

DJack
  • 631
  • 1
  • 8
  • 34

2 Answers2

1

Usually, to set up a cron job to run a script. You could use Perl for the scripts. And bash etc will do it as well.

HiroshiFuu
  • 311
  • 1
  • 2
  • 7
0

CRONTAB is simplest way. You should create simple shell script, it can be php file for interpreter too but in it you'll put only delete command. Crontab will carry on about 00:00 hour execution.

Kancho Iliev
  • 701
  • 5
  • 13
  • But in case I am not able to create a bash script what is the best alternative? To use a web-based cron service? Something like that: https://www.setcronjob.com – DJack May 03 '15 at 17:34
  • Do you mean if you are using third party hosting and haven't access to the system? If it is a case - I don't know - may be your solution is right then. I haven't used the service you mention - setcronjob.com, but probably there will be other limitations. For an example what if you haven't remote access to MySQL server and it can work only with localhost? – Kancho Iliev May 03 '15 at 17:42
  • By the way time trigger in MySQL is also not bad solution I think but I haven't do things like it and can't give advices. – Kancho Iliev May 03 '15 at 17:46