Running Ubuntu 16.04 I have added the following to /etc/crontab:

* * * * * root wget https://www.exmaple.org/bus/ >/dev/null 2>&1

The cron job runs properly, but the result is written as a file to /root/ rather than being discarded as expected.

1 Answer 1


>/dev/null discards the standard output of the command. There is none in your example. 2>&1 causes the standard error of the command to be discarded. In your example, this contains status and error information displayed by wget.

If the URL is valid (as in, if the server returns some content for the page), wget saves the content of the page in a file. This is neither displayed wget's standard output nor wget's standard error: it's some data that wget saves in a file. This is not affected by redirections, since wget is outputting to a file that it opens by name, not to a standard stream.

If you don't want to save the output anywhere, tell wget to save it to /dev/null:

wget -O /dev/null …

Note that errors from a cron job are useful to have, but Ubuntu discards them by default. The output of a cron job (standard output and standard error) is sent by local mail; see How are administrators supposed to read root's mail? for how to make that work. Annoyingly, wget produces a lot of output even when everything is working fine, it has no option to display only errors. You can work around this by saving the output and discarding it if the command is successful:

trace=$(wget … 2>&1) || echo "$trace" >&2
  • 1
    I suggest curl -sSfo /dev/null https://www.exmaple.org/bus/ instead of wget. s makes it silent, except (S) for errors. f makes it fail (exit) on errors. o /dev/null to kill the output. Curl in this case is less annoying than wget.
    – derobert
    Jun 4, 2017 at 0:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .