Running two commands sequentially in a cron job?

medo ampir picture medo ampir · Mar 9, 2012 · Viewed 81k times · Source

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?

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.

Answer

vincent picture vincent · Mar 9, 2012

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.