resting resting - 11 months ago 45
Bash Question

What is /dev/null 2>&1?

I found this piece of code in /etc/cron.daily/apf

/etc/apf/apf -f >> /dev/null 2>&1
/etc/apf/apf -s >> /dev/null 2>&1

It's flushing and reloading the firewall.

I don't understand the
>> /dev/null 2>&1

What is the purpose of having this in the cron? It's overriding my firewall rules.
Can I safely remove this cron job?


>> /dev/null redirects standard output (stdout) to /dev/null, which discards it.

(The >> seems sort of superfluous, since >> means append while > means truncate and write, and either appending to or writing to /dev/null has the same net effect. I usually just use > for that reason.)

2>&1 redirects standard error (2) to standard output (1), which then discards it as well since standard output has already been redirected.