Article Listing 1 Listing 2 Listing 3 jun2007.tar

Listing 3 replace_cron


#!/bin/sh
# Listing 3: replace_cron

. /etc/setenv_path

users=$@

if [ -z "$users" ]
then
    while read user
    do
        users="$users $user"
    done
fi

CRON_ALLOW=/etc/cron.d/cron.allow

for user in $users
do
    if grep -w $user $CRON_ALLOW
    then
        echo "Removing $user's cron..."
        crontab -r $user
        start_cron $user
    else
        echo "$user is not in $CRON_ALLOW"
    fi
done