相关疑难解决方法(0)

使用 bash 脚本安装 crontab

我创建了一个脚本来在 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
Run Code Online (Sandbox Code Playgroud)

脚本运行,并将这两行添加到 crontab。但是如果我再次运行脚本,它会再次添加这些行,因此我将有四行说相同的内容。我希望安装脚本运行时插入到 crontab 的行不会重复。我怎样才能做到这一点

linux bash cron

12
推荐指数
1
解决办法
3万
查看次数

标签 统计

bash ×1

cron ×1

linux ×1