运行MySQL查询的wget完成下载文件后, [英] Run MySQL Query after wget finishes downloading file

查看:477
本文介绍了运行MySQL查询的wget完成下载文件后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行在wget的一个特定的MySQL查询,这是在后台运行,下载完的文件。例如...

I need to run a specific mysql query upon wget, which is running in the background, finishes downloading a file. For example...

HTTP://domain/file.zip

然后运行:

更新 SET 状态 ='活'WHERE ID ='1234'

UPDATE table SET status = 'live' WHERE id = '1234'

我怎么会去这样做?

推荐答案

我会建议在子shell启动wget命令,这样可以保证它完成你运行你的mysql命令。在bash中,这是用括号完成。

I would recommend launching the wget command in a subshell so you can ensure it completes before you run your mysql command. In bash, this is done with parentheses.

也可以使用&放大器;&安培; 所以,只有当wget命令有一个成功的退出状态mysql命令运行

Also use && so that the mysql command runs only if the wget command has a success exit status.

#!/bin/sh
(
  wget "http://domain/file.zip" && mysql -u user -ppassword database -e "UPDATE..."
) &

在把明文密码的脚本不不一定是个好主意,因为它可以在 PS 房源进行查看。

Putting the password in plaintext in the script is not necessarily a good idea because it can be viewed in a ps listing.

相反,你可以依靠你的〜/ .my.cnf 文件中的 [客户] 部分。您也可以使用 MYSQL_PWD 环境变量。两个方案都意味着没有密码的命令上市可见。

Instead, you can rely on the [client] section in your ~/.my.cnf file. You can also use the MYSQL_PWD environment variable. Either of these solutions means there's no password visible in the command listing.

这篇关于运行MySQL查询的wget完成下载文件后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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