Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

What does 2>&1 means in crontab commands? [duplicate]

Writer Andrew Mclaughlin

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

1 Answer

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.