Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试设置一个 Cron 作业来删除日期字段超过三周的 MySQL 记录,但我无法弄清楚框中的字符串是什么。这是 Cron 管理屏幕的图片。有人可以帮忙吗? http://i46.tinypic.com/id4nsj.jpg
如果您知道要运行的查询,则可以-e在脚本的命令行中使用 mysql 的参数。因此,您的 cron 管理工具中的“运行命令”将是:
-e
mysql -u <username> -p<password> -h <name-of-mysql-server> <databasename> -e "<YOUR-QUERY-HERE>"
删除早于某个日期的记录的查询的一般结构是:
DELETE FROM [table] WHERE [column] < DATE_SUB(NOW(), INTERVAL 3 WEEK);