34 lines
1.3 KiB
Bash
Executable File
34 lines
1.3 KiB
Bash
Executable File
#!/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"
|
|
crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE')
|
|
# Create cron_MINUTE.sh cron
|
|
if [[ ! $crontest ]]; then
|
|
echo "* * * * * $MY_PATH/../cron_MINUTE.sh >> /tmp/astroport.log 2>&1" >> /tmp/mycron && crontab /tmp/mycron \
|
|
else
|
|
echo "Cannot operate, please check crontab -l" && exit 1
|
|
fi
|
|
# Clean
|
|
rm -f /tmp/mycron
|
|
|
|
exit 0
|