Fix for multiple crontab multiple entries

This commit is contained in:
itsmesid 2020-06-09 14:52:23 +05:30 committed by GitHub
parent 8a7479e9b6
commit 92d1386af7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -477,15 +477,14 @@ SpeedtestMode(){
SetCronTab() SetCronTab()
{ {
# Remove OLD # Remove OLD
crontab -l >crontab.tmp crontab -l > crontab.tmp
old=$(cat crontab.tmp | awk '/speedtest/ {print FNR}')
if [[ "$old" =~ ^[0-9]+$ ]]; then
crontab -l | sed -e "${old}d" >crontab.tmp
fi
# Add New
if [[ "$1" == "0" ]]; then if [[ "$1" == "0" ]]; then
sed -i '/speedtest/d' crontab.tmp
crontab crontab.tmp && rm -f crontab.tmp crontab crontab.tmp && rm -f crontab.tmp
else else
sed -i '/speedtest/d' crontab.tmp
mode=$(sed -n -e '/SPEEDTEST_MODE/ s/.*\= *//p' $setupVars) mode=$(sed -n -e '/SPEEDTEST_MODE/ s/.*\= *//p' $setupVars)
if [[ "$mode" =~ "official" ]]; then if [[ "$mode" =~ "official" ]]; then