I have created a script to install two scripts on to the crontab.
#!/bin/bash
sudo crontab -l > mycron
#echo new cron into cron file
echo "*/05 * * * * bash /mnt/md0/capture/delete_old_pcap.sh" >> mycron #schedule the delete script
echo "*/12 * * * * bash /mnt/md0/capture/merge_pcap.sh" >> mycron #schedule the merge script
#install new cron file
crontab mycron
rm mycron
The script runs, and add the two lines to the crontab. But if I run the script again, it adds those lines again , thus I will have four lines saying the same stuff. I want the install script to run such that, the lines inserted to the crontab do not repeat. How can I do that