Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Paste Description for drupal-db-maint.sh

From: http://michael.susens-schurter.com/blog/2007/08/03/drupal-database-maintenance-script/

drupal-db-maint.sh
Friday, August 3rd, 2007 at 10:22:38am MDT 

  1. #!/bin/sh
  2. echo `date` - Starting Drupal database maintenance
  3.  
  4. MYSQL_USERNAME='insert your MySQL username here'
  5. MYSQL_PASSWORD='insert your MySQL password here'
  6. MYSQL_DATABASE='insert your database name here'
  7.  
  8. # Note: 2592000 = sessions over 30 days old.
  9. # Adjust the timespan as desired.
  10. CLEAN_SESSIONS_SQL='DELETE FROM `sessions` WHERE `timestamp` < (UNIX_TIMESTAMP() - 2592000)'
  11. OPTIMIZE_CACHES_SQL='OPTIMIZE TABLE `cache` , `cache_filter` , `cache_menu` , `cache_page` , `cache_views` , `sessions`'
  12.  
  13. # Note: I have tons of modules installed.
  14. # I tried cleaning out their table names before posting, but you'll want to double check this SQL.
  15. OPTIMIZE_REST_SQL='OPTIMIZE TABLE `access` , `accesslog` , `aggregator_category` , `aggregator_category_feed` , `aggregator_category_item` , `aggregator_feed` , `aggregator_item` , `authmap` , `blocks` , `blocks_roles` , `boxes` , `client` , `client_system` , `comments` , `contact` , `files` , `file_revisions` , `filters` , `filter_formats` , `flood` , `history` , `invite` , `menu` , `node` , `node_access` , `node_comment_statistics` , `node_counter` , `node_revisions` , `node_type` , `permission` , `profile_fields` , `profile_values` , `role` , `search_dataset` , `search_index` , `search_total` , `sequences` , `system` , `term_data` , `term_hierarchy` , `term_node` , `term_relation` , `term_synonym` , `url_alias` , `users` , `users_roles` , `variable` , `vocabulary` , `vocabulary_node_types` , `watchdog`'
  16.  
  17. # Note: I run this script on a Linode which has limited IO.
  18. # Adding a short wait between commands lessens the load on the server.
  19. SLEEP_TIME=5
  20.  
  21. echo $CLEAN_SESSIONS_SQL | mysql -u $MYSQL_USERNAME -p$MYSQL_PASSWORD $MYSQL_DATABASE
  22. sleep $SLEEP_TIME
  23.  
  24. echo $OPTIMIZE_CACHES_SQL | mysql -u $MYSQL_USERNAME -p$MYSQL_PASSWORD $MYSQL_DATABASE > /dev/null
  25. sleep $SLEEP_TIME
  26.  
  27. echo $OPTIMIZE_REST_SQL | mysql -u $MYSQL_USERNAME -p$MYSQL_PASSWORD $MYSQL_DATABASE > /dev/null
  28.  
  29. echo `date` - Done with Drupal database maintenance

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation