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 ~]#
Linux: The whole world made it for you... This blog is a collection of things I come across either at home or at work as a Linux Administrator. I have worked as an Admin working with Solaris, SAN, Backups and Linux at the Enterprise level for over 16 years.