title: SQL Server 2008 - Shrinking the Transaction Log - Any way to automate?
body: <p>I went in and checked my Transaction log the other day and it was something crazy like 15GB.  I ran the following code:</p>
  
  <pre><code>USE mydb
  GO
  BACKUP LOG mydb WITH TRUNCATE_ONLY
  GO
  DBCC SHRINKFILE(mydb_log,8)
  GO
  </code></pre>
  
  <p>Which worked fine, shrank it down to 8MB...but the DB in question is a Log Shipping Publisher, and the log is already back up to some 500MB and growing quick.</p>
  
  <p>Is there any way to automate this log shrinking, outside of creating a custom "Execute T-SQL Statement Task" Maintenance Plan Task, and hooking it on to my log backup task?  If that's the best way then fine...but I was just thinking that SQL Server would have a better way of dealing with this.  I thought it was supposed to shrink automatically whenever you took a log backup, but that's not happening (perhaps because of my log shipping, I don't know).  </p>
  
  <p>Here's my current backup plan:</p>
  
  <ul>
  <li>Full backups every night</li>
  <li>Transaction log backups once a day, late morning (maybe hook the Log shrinking onto this...doesn't need to be shrank every day though)</li>
  </ul>
  
  <p>Or maybe I just run it once a week, after I run a full backup task? What do you all think?</p>