Skip to main content

Posts

Showing posts with the label automated crontab update

Update crontab from command line

I occasionally need to update the cron on a TON of hosts, and don't want to run crontab -e a TON of times.. crontab -l | grep 'chmod 666' == Add an entry to an existing crontab == if [ $? -ne 0 ] then   cat <(crontab -l) <(echo "* * * * * chmod 666 /u01/core/*") | crontab -   echo "NOTE: cron updated" else   echo "NOTE: cron was already updated" fi == Remove something from a crontab [root@dvgllpsmsapp13 ~]# crontab -l # Chmod something 0 0 * * * chmod 777 /tmp/test 0 0 * * * chown 777 /tmp/test [root@dvgllpsmsapp13 ~]# cat <(crontab -l | grep -vi chmod) | crontab - [root@dvgllpsmsapp13 ~]# crontab -l 0 0 * * * chown 777 /tmp/test [root@dvgllpsmsapp13 ~]#