You could use sem
which is part of GNU parallel
.
0 0 * * * root sem --jobs 1 --id MyQueue mysql -xxxxxx -pyyyyyyyyyyv -hlocalhost -e "call MyFunction1"
1 0 * * * root sem --jobs 1 --id MyQueue wget -N http://mywebsite.net/path/AfterMyFunction1.php
This cron config will first start the mysql
through sem
, which will put it in a kind of queue called MyQueue
. This queue will probably be empty, so the mysql
is executed immediately. A minute later, the cron will start another sem
which will put the wget
in the same queue. With --jobs 1
, sem
is instructed to execute only one job at a time in that particular queue. As soon as the mysql
has finished, the second sem
will run the wget
command. sem
has plenty of options to control the queueing behaviour. For example, if you add --semaphoretimeout -60
, a waiting job will simply die after 60 seconds.
The &&
solution is probably better, since it won't execute the second command when the first one fails. The sem
solution has the advantage that you can specify different cron settings, like a different user. And it will prevent overlapping cron jobs, if the cron interval is shorter than the job duration.