使用Cron作业删除表中的MySQL信息 [英] Delete MySQL information in table using Cron jobs

查看:58
本文介绍了使用Cron作业删除表中的MySQL信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cPanel,试图使用cron作业删除表中的所有数据,但是当我进入cPanel中的cron作业时,输入以下内容时出现错误:

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

我检查了我的电子邮件以完成cron作业,并收到以下消息消息:

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'

最近2个小时我一直在研究此问题,但我没有找到有关如何从cPanel运行cron作业以删除表中所有信息的任何信息。

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.

该数据库名为tragicco_patron,该表名为patron_joined。非常感谢您的帮助!

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

推荐答案

您必须像这样调用CLI mysql-client:

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;"

这篇关于使用Cron作业删除表中的MySQL信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆