Sometimes log files can grow to the point when you just need to trim off some of the content from the start of the file i.e. the first x number of lines. This can be done easily with the following command
sed -i -e <start line number> , <end line number>d <filename>
rsync is great to keep two folders or machines in sync, either locally or remotely. However, there are loads of command line options that can look complex for the initial user.
I have used the following command to sync one folder to another –
rsync [options] [source] [destination]
rsync -anvP /mnt/hda/pictures/2007/ /mnt/windows/pictures/2007
Notice that when you specify the source you must have a trailing ‘/’ to indicate the source directory. The destination is then specified by the directory you want to sync the files into.
By default rsync will not delete any files in the destination that it does not find in the source.
In the example above –
a – archive, this will sync folders recursively and deals with symbolic links and other special files. It also preserves dates, times, owners etc.
n – dry run – just show on the screen what will be done. Nothing is actually moved, created/deleted.
v – verbose, additional output onscreen.
P – Progress & Partial, shows progress of transfers and also allows restart after partial sync.
You may have noticed in the above example that both folders are in /mnt/…… I am using a Centos server to sync some folders from a HDA NAS system back to a Windows Home Server. Both systems are presenting shared drives that the Centos server has mounted and is then scanning in order to complete the rsync. The windows files shares are mounted using mount.
mount -t cifs -o user=centos //220.127.116.11/pictures /mnt/hda/pictures/
mount -t cifs -o user=windows //18.104.22.168/pictures /mnt/windows/pictures/
When entering the above commands you will be prompted for the password of the user supplied in order to access the fileshare.