Go offline with the Player FM app!
HPR2113: sqlite and bash
Archived series ("Inactive feed" status)
When? This feed was archived on February 10, 2021 18:12 (). Last successful fetch was on February 26, 2021 20:39 ()
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
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
3280 episodes
Archived series ("Inactive feed" status)
When? This feed was archived on February 10, 2021 18:12 (). Last successful fetch was on February 26, 2021 20:39 ()
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
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
3280 episodes
All episodes
×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.