Listing 1 stop_cron
#!/bin/sh
# Listing 1: stop_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
SORTINGHAT_DIR=/opt/SortingHat
for user in $users
do
if grep -w $user $CRON_ALLOW
then
echo "Stopping ${user}'s cron..."
file=/var/spool/cron/crontabs/$user
if [ -f $file ]
then
$SORTINGHAT_DIR/bin/SortingHat -b $file
fi
crontab -r $user
echo "${user}'s cron has been stopped."
else
echo "$user is not in $CRON_ALLOW"
fi
done
|