<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: cron code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 07:11:47 GMT</pubDate>
    <description>DZone Snippets: cron code</description>
    <item>
      <title>Rip an Icecast stream</title>
      <link>http://snippets.dzone.com/posts/show/4684</link>
      <description>Rip an Icecast stream (for a 30 min duration), and direct the streamripper text including errors to /dev/null.  Note: Directing the output to null is necessary when running this within a cron job.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;streamripper http://192.168.1.7:8000/radio_x.ogg.m3u -dq  ~james/Streamripper_rips/hay -a %d -l 1800 &gt;/dev/null 2&gt;&amp;1&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 21 Oct 2007 23:28:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4684</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>truncate Rails development/test logs</title>
      <link>http://snippets.dzone.com/posts/show/4399</link>
      <description>In rails applications development.log and test.log like to grow forever, which takes up space and makes them slow to grep.  If I just delete them running processes with logs open might get confused.  So I can use truncate instead:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;truncate ~/www/*/log/*.log&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Even easier, ask cron to do it for me every night:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;4 22 * * * * truncate -s 0k  ~/www/*/log/*.log&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 07 Aug 2007 17:17:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4399</guid>
      <author>laurelfan (Laurel Fan)</author>
    </item>
    <item>
      <title>Simple mySQL backup script for cron</title>
      <link>http://snippets.dzone.com/posts/show/4172</link>
      <description>Simple mySQL backup script for cron - backs up all databases, saves the last 4 copies.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;# modify the following to suit your environment&lt;br /&gt;export DB_BACKUP="/backup/mysql_backup"&lt;br /&gt;export DB_USER="root"&lt;br /&gt;export DB_PASSWD="********"&lt;br /&gt;&lt;br /&gt;# title and version&lt;br /&gt;echo ""&lt;br /&gt;echo "mySQL_backup"&lt;br /&gt;echo "----------------------"&lt;br /&gt;echo "* Rotating backups..."&lt;br /&gt;rm -rf $DB_BACKUP/04&lt;br /&gt;mv $DB_BACKUP/03 $DB_BACKUP/04&lt;br /&gt;mv $DB_BACKUP/02 $DB_BACKUP/03&lt;br /&gt;mv $DB_BACKUP/01 $DB_BACKUP/02&lt;br /&gt;mkdir $DB_BACKUP/01 &lt;br /&gt;&lt;br /&gt;echo "* Creating new backup..."&lt;br /&gt;mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | bzip2 &gt; $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.bz2&lt;br /&gt;echo "----------------------"&lt;br /&gt;echo "Done"&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 20 Jun 2007 15:01:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4172</guid>
      <author>fak3r (fak3r)</author>
    </item>
    <item>
      <title>Backup MySQL databases into seperate files</title>
      <link>http://snippets.dzone.com/posts/show/988</link>
      <description>A cronable script for backing up all your databases as seperate files.  I'd suggest limiting the backup user's access to the IP of the computer backing up, and using some sort of encryption if you're on a capable version of mysql.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# MySQL backups from the Data&lt;br /&gt;&lt;br /&gt;MOUNTED=`grep /etc/mtab -e \/mnt\/backup`&lt;br /&gt;if [ "$MOUNTED" = '' ]; then&lt;br /&gt;        echo "/mnt/backup is not mounted, there is no drive to backup to"&lt;br /&gt;        exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mkdir -p /mnt/backup/cluster_sql&lt;br /&gt;&lt;br /&gt;for i in $(echo 'SHOW DATABASES;' | mysql -ubackup -pSUPERSECRET -hData|grep -v '^Database$'); do&lt;br /&gt;  mysqldump -ubackup -pSUPERSECRET -hData --opt $i &gt; /mnt/backup/cluster_sql/$i.sql;&lt;br /&gt;done;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 20 Dec 2005 12:50:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/988</guid>
      <author>mixonic (Matthew Beale)</author>
    </item>
    <item>
      <title>Automatically erase Ruby on Rails session files</title>
      <link>http://snippets.dzone.com/posts/show/729</link>
      <description>Add to your cron:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;1 */4 * * *     find /tmp/ -name "ruby_sess*" -cmin +600 -exec rm \{} \;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Deletes sessions over ten hours old every four hours. Otherwise your /tmp will end up overflowing. This only applies you use the file store method of session storage with Rails.</description>
      <pubDate>Fri, 16 Sep 2005 22:53:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/729</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
  </channel>
</rss>
