Last active
April 18, 2016 15:09
-
-
Save fedir/5162747 to your computer and use it in GitHub Desktop.
Empty TYPO3 cache via shell // using bash condition on table existence in mysql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DB=$1 | |
echo "Empty cache dB $DB" | |
function empty_table { | |
TABLE=$1 | |
if [ $(mysql -N -s -e "select count(*) from information_schema.tables where table_schema='$DB' and table_name='$TABLE';") -eq 1 ]; | |
then | |
mysql $DB -e "TRUNCATE $TABLE" | |
else | |
echo "table $DB.$TABLE does not exist" | |
fi | |
} | |
TABLES_TO_EMPTY=("cache_extensions" "cache_hash" "cache_imagesizes" "cache_md5params" "cache_pages" "cache_pagesection" "cache_treelist" "cache_typo3temp_log" "cachingframework_cache_hash" "cachingframework_cache_hash_tags" "cachingframework_cache_pages" "cachingframework_cache_pagesection" "cachingframework_cache_pagesection_tags" "cachingframework_cache_pages_tags" "sys_log" "sys_history" "be_sessions" "fe_sessions" "fe_session_data" "index_debug" "index_fulltext" "index_grlist" "index_phash" "index_rel" "index_section" "index_stat_search" "index_stat_word" "index_words" "tx_realurl_errorlog" "tx_realurl_pathcache" "tx_realurl_uniqalias" "tx_realurl_urldecodecache" "tx_realurl_urlencodecache" "tx_realurl_chashcache") | |
for TABLE_TO_EMPTY in "${TABLES_TO_EMPTY[@]}"; | |
do | |
empty_table $TABLE_TO_EMPTY | |
done | |
echo "Cache dB $DB cleared" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment