What Does 2>&1 Means in Crontab Commands? [Duplicate]

I've seen many crontab commands written this way:

*/5 * * * * ~/script.sh >/dev/null 2>&1

Can someone explain what is the exact meaning of 2>&1?

2

It's redirecting standard error to standard output using file descriptors.

This isn't a cron construct but a shell construct and is available in pretty much any shell you may come across. 2 is the file descriptor for STDERR and 1 is the file descriptor for STDOUT. The > sign is the redirection operator.

More information about file descriptors and shell redirection can be found here.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest