Archive for July, 2010

Keeping the Time Current on a Linux Server


apt-get install rdate
rdate -s time-a.nist.gov
crontab -e
34 3 * * * /usr/bin/rdate -s time-a.nist.gov

See http://www.pool.ntp.org/zone/@ if the above ntp server doesn’t work for you.

Comments

Backup a folder

I usually keep this script in the
“/usr/bin/archive” file and make it executable.

#!/bin/bash

FOLDER=$1
NOW=$(date +"%Y-%m-%d")

OUTPUT="tar -cjf $FOLDER-$NOW.tar.bz $FOLDER"
echo $OUTPUT
$OUTPUT

Usage:

$ archive folder_name

Will create a file “folder_name-2010-07-18.tar.bz” in the current directory. Then you can rm -rf the folder and copy the archive to your archived location.

This goes well with “/usr/bin/archive_all”

#!/bin/bash

for file in *;
do
if [ -d "$file" ]; then
archive "$file";
fi

done;

This will create archives of all the subdirectories in the current directory. This is good for archiving old projects that don’t need to be uncompressed anymore.

Comments