Delete MySQL information in table using Cron jobs

跟風遠走 提交于 2019-12-25 07:59:24

问题


I am using cPanel, trying to use cron jobs to delete all data in a table, but when I went to cron jobs in cPanel, I got an error when I put in the following:

DELETE FROM patron_joined WHERE uid < NOW() - INTERVAL 1 MINUTE

I checked my email for completion of the cron job and received the following message:

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `DELETE FROM patron_joined WHERE uid < NOW() - INTERVAL 1 
MINUTE'

I have been researching this issue for the last 2 hours and I haven't found any information on how to run a cron job from cPanel to delete all info in a table.

The database is named tragicco_patron and the table is patron_joined. Any help is greatly appreciated!


回答1:


You have to invoke CLI mysql-client like this:

0 23 * * * * root /usr/bin/mysql -e "USE mydatabase; DELETE FROM patron_joined WHERE uid < NOW() - INTERVAL 1 MINUTE;"


来源:https://stackoverflow.com/questions/23922940/delete-mysql-information-in-table-using-cron-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!