Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jan 072010
 

Meaning of 2>&1 in crontab

Answer:

It is quite common to find the following line in crontab

32 5 * * * root /project/cron.sh >> /dev/null 2>&1

The meaning of 2>&1 at the end of line means to redirect the standard error stream (stderr) to the standard out stream (stdout), and finally redirect everything to /dev/null.

It is commonly used in crontab definition so if a given command return too much warnings, it will not be logged anywhere in the system in order to reduce the storage requirements.

Jan 072010
 

How to redirect error message to a file

Answer:

Assume you have some program/script that print to the standard error stream (i.e. stderr)

E.g. error.pl

print STDERR 'error';

You cannot redirect the error message just by basic file redirection, e.g.

perl error.pl > error.txt

Instead, you need to use 2>

perl error.pl 2> error.txt

Jan 072010
 

Disable IPv6 in Linux

Answer:

To disable IPv6 during boot time.

1. edit /boot/grub/menu.lst

# sudo vi /boot/grub/menu.lst

2. append the following line at the end of your targeted kernel, save the file.

ipv6.disable=1

3. Restart your system and verify to see it is now disabled (The following command should return nothing)

# ip a | grep inet6