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!

Dec 312009
 

How to check the current logrotate status?

Answer:

logrotate will maintain a status file, normally at the location /var/lib/logrotate/status , you can view the content of this file to see the latest status of all log files managed by logrotate.

Example:

logrotate state -- version 2
"/var/log/apache2/access.log" 2008-12-7
"/var/log/apache2/error.log" 2009-1-25
...

Therefore, it is useful to verify if your desired log files are controlled by logrotate or not.

Dec 312009
 

How to mirror a directory to a remote server over SSH?

Answer:

You can use rsync command for this purpose

Assume you want to mirror the local folder "/home/john" to remote server 192.168.1.5, under the folder "/data/backup/", you need to use the following command

rsync -avuz -e ssh /home/john 192.168.1.5:/data/backup/

If you want to dry-run the rsync, use the "n" flag, e.g.

rsync -avuzn -e ssh /home/john 192.168.1.5:/data/backup/

For more options, checkout the rsync document: http://www.samba.org/ftp/rsync/rsync.html

Dec 312009
 

How to adjust the argument position in xargs?

Answer:

Sometimes you might want to adjust the argument position when using the xargs command, e.g.

echo "foo" | xargs echo "bar"

It gives:

bar foo

Instead, you want the piped argument "foo" to be inserted before the "bar", you can use

echo "foo" | xargs -i echo {} "bar"

Now it gives:

foo bar

That's very handy