Archive for the tag 'automatic'

Configure Automatic Update Retrieval and Installation with Cron

The yum-updatesd service is not mature enough for an enterprise environment, and the service may introduce unnecessary overhead. When possible, replace this service with a cron job that calls yum directly.

Disable the yum-updatesd service:

# chkconfig yum-updatesd off

Create the file yum.cron, make it executable, and place it in /etc/cron.daily:

#!/bin/sh
/usr/bin/yum -R 120 -e 0 -d 0 -y update yum
/usr/bin/yum -R 10 -e 0 -d 0 -y update

This particular script instructs yum to update any packages it finds. Placing the script in
/etc/cron.daily ensures its daily execution.
To only apply updates once a week, place the script in /etc/cron.weekly instead.

We can set up an automatic rsync and place the files into daily folders. For this to work we need to setup automatic ssh login first and then use cron to run your bash script.

The base of the automatic rsync is a very simple bash script.

#!/bin/bash
dest=/backup/buddy/`date +%A`
mkdir -p $dest
rsync -e ’ssh -p 2222′ -avl –delete –stats –progress root@192.168.1.1:/home/buddy $dest/

Using Cron to run the above script every day.

# run rsync at 23.00hrs every day
00 23 * * * sh /home/backup/bin/backup