What is the meaning of the "/dev/null 2>&1" in a Cronjob entry?
Solution 1:
It means that stderr
(2
- containing error messages from the executed command or script) is redirected (>&
) to stdout
(1
- the output of the command) and that the latter is being redirected to /dev/null
(the null device).
This way you can suppress all messages that might be issued by the executed command. In cron this is often done to avoid being spammed by lots of irrelevant messages from service scripts. Nevertheless be careful with this as some messages might be important.
More information on output redirects can be found in The Linux Documentation Project here and here. The null device is described here.