File: //var/tmp0/brainy/ssh/crontab
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments provided"
exit 1
fi
action=$1;
os=$2;
if [ "${action}" == "install" ]; then
if [ "${os}" == "debian8" ]; then
apt-get install cron -y --force-yes
systemctl enable cron
systemctl start cron
elif [ "${os}" == "ubuntu" ]; then
apt-get -y install cronie
systemctl enable crond
systemctl start crond
else
yum -y install cronie
service crond start
chkconfig crond on
fi
fi
if [ "${action}" == "delete" ]; then
if [ "${os}" == "debian8" ]; then
systemctl stop cron
apt-get remove cron -y && aptitude purge ~c -y
elif [ "${os}" == "ubuntu" ]; then
systemctl stop crond
apt-get -y remove --purge cronie
else
service stop cron
yum -y erase cronie
fi
fi
if [ "${action}" == "reinstall" ]; then
if [ "${os}" == "debian8" ]; then
systemctl cron stop
apt-get remove cron -y && aptitude purge ~c -y
apt-get install cron -y --force-yes
systemctl enable cron
systemctl start cron
elif [ "${os}" == "ubuntu" ]; then
systemctl stop crond
apt-get -y remove --purge cronie
apt-get -y install cronie
systemctl enable cron
systemctl start cron
else
yum -y erase cronie
yum -y install cronie
service crond start
chkconfig crond on
fi
fi