#!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) # Version: 2020.03.21 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" echo ' ######################################################################## # \\/// # qo-op ############# '$MY_PATH/$ME' ######################################################################## # ex: ./'$ME' # VERIFY CRON for cron_MINUTE.sh and ACTIVATE it ########################################################################' # Get crontab crontab -l > /tmp/mycron # Remove any previous line containing "cron_MINUTE" awk -i inplace -v rmv="cron_MINUTE" '!index($0,rmv)' /tmp/mycron && echo "Astroport cron was there" # DOUBLE CHECK (awk = nawk or gawk -i ?) crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE') # ADD cron_MINUTE.sh TO cron ? if [[ ! $crontest ]]; then echo "* * * * * $MY_PATH/../cron_MINUTE.sh >> /tmp/astroport.log 2>&1>/dev/null" >> /tmp/mycron && crontab /tmp/mycron \ else echo "No operation needed. Your crontab is: " && crontab -l fi # Clean rm -f /tmp/mycron exit 0