3

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 1

6

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.

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