Skip to content

Instantly share code, notes, and snippets.

@astehlik
Created January 15, 2016 17:30
Show Gist options
  • Save astehlik/151f62e17ba2afd6e9ea to your computer and use it in GitHub Desktop.
Save astehlik/151f62e17ba2afd6e9ea to your computer and use it in GitHub Desktop.
Cronjob for checking TYPO3 Scheduler task disabled state and database triggers
#!/bin/bash
mysql_user="xxx"
mysql_pass="xxx"
mysql_db="xxx"
mysql="mysql --skip-column-names -u $mysql_user -p$mysql_pass -D $mysql_db"
messages=""
# Appends an error message to the output
# Parameter 1: the message to append
function appendMessage {
messages="$messages\n- $1"
}
# Checks if the task with the given UID is active
# Parameter 1: the uid of the task to check
# Parameter 2: the name of the task
function checkForActiveTask {
crawlerActive=`echo "SELECT COUNT(*) FROM tx_scheduler_task WHERE uid=$1 AND disable=0" | ${mysql}`
if [ ! "$crawlerActive" -eq "1" ]; then
appendMessage "$2 task is not active"
fi
}
# Checks if the trigger with the given name exists in the databsae
# Parameter 1: the name of the trigger
# Parameter 2: the name of the task
function checkForTrigger {
triggerActive=`echo "SHOW TRIGGERS" | ${mysql} | grep $1`
if [ -z "$triggerActive" ]; then
appendMessage "$1 trigger does not exist"
fi
}
checkForActiveTask 5 Crawler
checkForActiveTask 11 "Solr Indexer"
checkForActiveTask 8 "Cache Garbage Collection"
checkForTrigger myRequiredTrigger1
checkForTrigger myRequiredTrigger2
if [ ! -z "$messages" ]; then
echo ""
echo "Warning! System state of -`hostname -f`- is not optimal."
echo ""
echo "Please check the following errors:"
echo -e ${messages}
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment