"test sys_refresh_ref_cron.sh"

This commit is contained in:
Doug Le Tough 2017-07-25 12:50:21 +02:00
parent 8ddb9f1555
commit 39729c1c23
1 changed files with 3 additions and 7 deletions

View File

@ -176,17 +176,13 @@ function refresh_cronjobs
MONTHS=$(echo ${CRONJOB} | cut -d' ' -f4) MONTHS=$(echo ${CRONJOB} | cut -d' ' -f4)
DAYOFWEEK=$(echo ${CRONJOB} | cut -d' ' -f5) DAYOFWEEK=$(echo ${CRONJOB} | cut -d' ' -f5)
COMMAND=$(echo ${CRONJOB} | cut -d' ' -f6-) COMMAND=$(echo ${CRONJOB} | cut -d' ' -f6-)
REQUEST_ID_PARAMS="host='${VM}' and s_user='${TETALAB_USER}' and minutes='${MINUTES}' 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}'"
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}', REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}', '${HOURS}', '${DAYS}', '${DAYSOFWEEKS}', '${COMMAND}'"
'${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});"
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