sed remove cron entry

Hello,
I am not having much luck with removing a entry in cron. I would like to get rid of the following line in /var/spool/cron/root.

1    09   *   *   1-5 /etc/init.d/snmpd stop > /dev/null 2>&1

I have tried this with no luck.

sed -i 's#1    09   *   *   1-5 /etc/init.d/snmpd stop > /dev/null 2>&1##g' /var/spool/cron/root

Any suggestions are welcome. ,

jaysunn

How about editing crontab file using crontab -e option?

Rather than matching whole line why no just match on the "snmpd stop" string:

sed -i '/snmpd stop/d' /var/spool/cron/root
1 Like

That seems like a logical approach, I forgot to mention that I need to do this on 75 servers without configuration management software, so the

crontab

command on each is not feasible.

My current approach was a

for loop

through each system "ssh keys configured" and remove the line.

Thanks for your help,

jaysunn