在 cron 作业中按顺序运行两个命令? [英] Running two commands sequentially in a cron job?

查看:27
本文介绍了在 cron 作业中按顺序运行两个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这样的 cron 作业中有两个命令:

I have two commands in a cron job like this:

mysql -xxxxxx -pyyyyyyyyyyv -hlocalhost -e "call MyFunction1";wget -N http://mywebsite.net/path/AfterMyFunction1.php

但在我看来它们是同时运行的.

but it seems to me that both of them are running at the same time.

如何运行第一个命令并在它完成后执行第二个命令?

How can I make the first command run and when it completes, execute the second command?

当我使用 wget 时,AfterMyFunction1.php 也有不执行的 javascript http 请求.如果我在我的网络浏览器中打开 AfterMyFunction1.php,它会起作用.

Also the AfterMyFunction1.php have javascript http requests that are not executed when I use wget. It works if I opened AfterMyFunction1.php in my webbrowser.

推荐答案

如果第一条命令需要先完成,你应该用 &&运算符 就像在shell 中一样.如果第一个失败,第二个将不会运行.

If the first command is required to be completed first, you should separate them with the && operator as you would in the shell. If the first fails, the second will not run.

这篇关于在 cron 作业中按顺序运行两个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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