"test sys_refresh_ref_cron.sh"
This commit is contained in:
parent
39729c1c23
commit
4532c10cb3
@ -170,19 +170,23 @@ function refresh_cronjobs
|
|||||||
if [ ${#CRONJOB} -gt 0 ]; then
|
if [ ${#CRONJOB} -gt 0 ]; then
|
||||||
fct_message "Checking database:"
|
fct_message "Checking database:"
|
||||||
CRONJOB="$@"
|
CRONJOB="$@"
|
||||||
MINUTES=$(echo ${CRONJOB} | cut -d' ' -f1)
|
MINUTES=$(echo ${CRONJOB} | awk -F ' ' '{print $1}')
|
||||||
HOURS=$(echo ${CRONJOB} | cut -d' ' -f2)
|
HOURS=$(echo ${CRONJOB} | awk -F ' ' '{print $2}')
|
||||||
DAYS=$(echo ${CRONJOB} | cut -d' ' -f3)
|
DAYS=$(echo ${CRONJOB} | awk -F ' ' '{print $3}')
|
||||||
MONTHS=$(echo ${CRONJOB} | cut -d' ' -f4)
|
MONTHS=$(echo ${CRONJOB} | awk -F ' ' '{print $4}')
|
||||||
DAYOFWEEK=$(echo ${CRONJOB} | cut -d' ' -f5)
|
DAYOFWEEK=$(echo ${CRONJOB} | awk -F ' ' '{print $5}')
|
||||||
COMMAND=$(echo ${CRONJOB} | cut -d' ' -f6-)
|
COMMAND=$(echo ${CRONJOB} | awk -F ' ' '{$1=$2=$3=$4=$5=""; print $0}')
|
||||||
REQUEST_ID_PARAMS="host='${VM}' and s_user='${TETALAB_USER}' and minutes='${MINUTES}' and hours='${HOURS}' and days='${DAYS}' and daysofweek='${DAYSOFWEEKS}' and command='${COMMAND}'"
|
REQUEST_ID_PARAMS="host='${VM}' and s_user='${TETALAB_USER}' and minutes='${MINUTES}'
|
||||||
|
and hours='${HOURS}' and days='${DAYS}' and daysofweek='${DAYSOFWEEKS}' and command='${COMMAND}'"
|
||||||
RESULT=$(psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
RESULT=$(psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
||||||
ref_cron where ${REQUEST_ID_PARAMS};")
|
ref_cron where ${REQUEST_ID_PARAMS};")
|
||||||
if [ ${#RESULT} -eq 0 ]; then
|
if [ ${#RESULT} -eq 0 ]; then
|
||||||
fct_message "Cronjob not in database, inserting..."
|
fct_message "Cronjob not in database, inserting..."
|
||||||
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}', '${HOURS}', '${DAYS}', '${DAYSOFWEEKS}', '${COMMAND}'"
|
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}',
|
||||||
psql -e -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron (\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"daysofweek\", \"command\") values (${REQUEST_INSERT_PARAMS});"
|
'${HOURS}', '${DAYS}', '${DAYSOFWEEKS}', '${COMMAND}'"
|
||||||
|
psql -e -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron
|
||||||
|
(\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"daysofweek\", \"command\")
|
||||||
|
values (${REQUEST_INSERT_PARAMS});"
|
||||||
else
|
else
|
||||||
fct_message "Cronjob already in database"
|
fct_message "Cronjob already in database"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user