Artwork

Content provided by HPR Volunteer and Hacker Public Radio. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by HPR Volunteer and Hacker Public Radio or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

HPR2113: sqlite and bash

 
Share
 

Archived series ("Inactive feed" status)

When? This feed was archived on February 10, 2021 18:12 (3+ y ago). Last successful fetch was on February 26, 2021 20:39 (3+ y ago)

Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.

What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.

Manage episode 160035120 series 49648
Content provided by HPR Volunteer and Hacker Public Radio. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by HPR Volunteer and Hacker Public Radio or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Crontab

0 3 * * 0 /bin/du -m /data/ > /home/USER/du_files/"du_$(/bin/date +\%Y\%m\%d)"

Script

cd ~/du_files TODAYS_FILE="du_$(/usr/bin/date +%Y%m%d)" YESTERDAYS_FILE="du_$(/usr/bin/date --date="7 days ago" +%Y%m%d)" /usr/bin/echo "create table old (oldsize integer, path varchar);" > delta.sql /usr/bin/echo "create table new (newsize integer, path varchar);" >> delta.sql /usr/bin/echo '.separator "\t" ' >> delta.sql /usr/bin/echo ".import $TODAYS_FILE new" >> delta.sql /usr/bin/echo ".import $YESTERDAYS_FILE old" >> delta.sql /usr/bin/echo ".mode csv" >> delta.sql /usr/bin/echo ".headers on" >> delta.sql /usr/bin/echo ".out deltas.csv" >> delta.sql /usr/bin/echo "select *,newsize-oldsize as delta_in_megabytes from old natural join new where oldsize> delta.sql /usr/bin/sqlite3 < delta.sql echo $YESTERDAYS_FILE|/usr/bin/mailx -a deltas.csv -s deltas.csv me@mywork.com

Resulting SQL

create table old (oldsize integer, path varchar); create table new (newsize integer, path varchar); .separator "\t" .import du_20160821 new .import du_20160814 old .mode csv .headers on .out deltas.csv select *,newsize-oldsize as delta_in_megabytes from old natural join new where oldsize
  continue reading

3280 episodes

Artwork

HPR2113: sqlite and bash

Hacker Public Radio

74 subscribers

published

iconShare
 

Archived series ("Inactive feed" status)

When? This feed was archived on February 10, 2021 18:12 (3+ y ago). Last successful fetch was on February 26, 2021 20:39 (3+ y ago)

Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.

What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.

Manage episode 160035120 series 49648
Content provided by HPR Volunteer and Hacker Public Radio. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by HPR Volunteer and Hacker Public Radio or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

Crontab

0 3 * * 0 /bin/du -m /data/ > /home/USER/du_files/"du_$(/bin/date +\%Y\%m\%d)"

Script

cd ~/du_files TODAYS_FILE="du_$(/usr/bin/date +%Y%m%d)" YESTERDAYS_FILE="du_$(/usr/bin/date --date="7 days ago" +%Y%m%d)" /usr/bin/echo "create table old (oldsize integer, path varchar);" > delta.sql /usr/bin/echo "create table new (newsize integer, path varchar);" >> delta.sql /usr/bin/echo '.separator "\t" ' >> delta.sql /usr/bin/echo ".import $TODAYS_FILE new" >> delta.sql /usr/bin/echo ".import $YESTERDAYS_FILE old" >> delta.sql /usr/bin/echo ".mode csv" >> delta.sql /usr/bin/echo ".headers on" >> delta.sql /usr/bin/echo ".out deltas.csv" >> delta.sql /usr/bin/echo "select *,newsize-oldsize as delta_in_megabytes from old natural join new where oldsize> delta.sql /usr/bin/sqlite3 < delta.sql echo $YESTERDAYS_FILE|/usr/bin/mailx -a deltas.csv -s deltas.csv me@mywork.com

Resulting SQL

create table old (oldsize integer, path varchar); create table new (newsize integer, path varchar); .separator "\t" .import du_20160821 new .import du_20160814 old .mode csv .headers on .out deltas.csv select *,newsize-oldsize as delta_in_megabytes from old natural join new where oldsize
  continue reading

3280 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide