You should protect the URL with double quotes to prevent the shell from parsing the =
, ?
, and &
as being special instead of just plain old characters.
Also, as a minor nitpick, you should use fgrep
because grep
will treat the .
characters as being 'match any character' and not as a literal .
. fgrep
treats the whole string it's searching for (except for \n
) as literal. But this is unlikely to cause you problems in practice.
The programmer in me shudders at this approach because so many things could potentially go wrong. In practice, they almost certainly won't. But I've learned to never, ever write programs as if the things I think should never happen never will. Because, in practice, they almost all do eventually.
For example, if you ever try to do two different fetches with different parameters at the same time, one will mysteriously not happen.
Also, if some random person happens to have put that URL on the command line for something, that will cause the script to not do anything until whatever command it is finishes.
As I said, these may or may not be serious problems. But I would be aware of them.
pidof
orpsgrep
rather than parsing the output ofps
, to avoid potential false positives … ? \$\endgroup\$