Why does it work? What happened?

All of a sudden! (That’s a Tourniquet reference) One week ago, my cron jobs started working. I’m very happy and very confused. I pulled what I’ll loosely call “reports” on various random artists to compare what time batches of data were pulled from Spotify to the times I set in the crontab — wondering if it was some weird fluke or maybe I’d done it manually (in the middle of the night) and just forgotten.

Good News: No ghosts or gremlins — they’re actually working.

When I got to Bloodgood, I received quite a shock.  Their #1 song was from their latest album. But wait, there’s more — these are their Top 25 tracks on Spotify:

bloodGoodTracksTop25.png

Not only are most of them from Dangerously Close (2013) but most of the rest are from Out of the Darkness.

I would have thought the list would be dominated by tracks from Metal Missionaries and Detonation. I gave Dangerously Close a try when it was first released but didn’t like it and I only ever liked one song enough to remember it from Out of the Darkness (“Top of the Mountain” which appears twice in the top 25).

As it turns out, one need look no further to find evidence of how out of touch I am with other Bloodgood fans than the ranking of Rock in a Hard Place — my personal favorite Bloodgood album. It ranks last among their studio albums with the exception of … whoa … I thought Metal Missionaries was at the bottom because it’s a “25th Anniversary Edition” but there’s no “regular” edition elsewhere on the list.

BloodgoodAlbumsRanked.png

I think I need to go back and listen to those last two albums … maybe I missed something.

However …

while requests for 12th Tribe data finally seem to be working (for some reason, they weren’t for a while), artist popularity for One Bad Pig has only been fetched (using the term loosely) twice and not since the middle of last December. Album and Track data is up-to-date but nothing for artist popularity. The same arrays are used for all of them … well, maybe it’s what my browser pulled just now and not really what’s in my database … hold on … nope, MySQL Workbench gives me just the same two rows.

Well, I’ll be …

One Bad Pig‘s latest album, Love You to Death (2016) is tied for first place as well. Wow, I thought that album kinda sucked, too. It’s tied with I Scream Sunday (1991) which … is their second most-recent album.

I keep waiting to exhale so I can maybe start working on the data viz for all of this …

Advertisements

My First Cron Job(s)

Learning from this great “Automated Tasks” page at CentOS.org

Normally, I prefer stuff like this in a well-written tutorial (see below awesomeness from DigitalOcean) but the above is … wow.

Tangent Sidebar: You know what’s kind of irritating? How I use DigitalOcean documentation all the time — not just because it’s higher in the Google results but it is so much better than the documentation of my actual host. Far more subjects, ridiculously specific, much better written, and far more accurate.

Two cases in point:

The latter is especially useful today because I keep getting emails from Let’s Encrypt reminding me to renew my shizzle.

But, as it turns out, none of those told me exactly what I needed but this did:

How to run PHP scripts from cron jobs

That’s my host. I’m very proud of them. And if their customer support is ever consistently good or consistently “not bad,” I’ll totally apologize. Interestingly, that tute gave me the final piece I needed but if I hadn’t read the other tutes first I’d still have no idea what to do because it only gave the final step, not the first several. That’s my host.

The first three (the good) tutorials taught me how to write a line in the crontab using the columns:

  • minute
  • hour
  • day
  • month
  • dayofweek
  • command

“How to Use Cron …” even gave me the “shortcut” of using @weekly instead of 00**0.

But Newbie: Intro to Cron which I think — sincerely and seriously — is a beautifully designed page, gave me the best tip in telling me to look for the following folders in my /etc directory:

  • cron.daily
  • cron.hourly
  • cron.monthly
  • cron.weekly

Dude. Just drop a script in one of those and viola!

And … and … earlier, one of those tutorials stated, “Cron is a daemon …” and I wondered, “What is a daemon?” That Newbie tute said,

Cron is a daemon, which means that it only needs to be started once, and will lay dormant until it is required. A Web server is a daemon, it stays dormant until it gets asked for a web page. The cron daemon, or crond, stays dormant until a time specified in one of the config files, or crontabs.

I wish cogNiTioN wrote every tutorial on all of the sites and I wish all of the sites were designed like that one.

Okay, so I write a line in my crontab telling it to change directories to where I keep a certain php file, then use php to run that file. Like so …

00 16 * * * user-name cd /my/directory/path; php -q myfile.php

It’s almost 3:30pm now so in a little over half an hour, I’ll check to see if it worked. I’d love that. I’m rather sick of trying to remember to do this particular task.

I had it change directories first because from what I understand, the relative paths in the file would get all confused and fail if the little crontab tried to run the commands from /etc.

If you’re still reading and you care, it’s a script that will go grab popularity scores from Spotify for a bunch of artists I’m tracking.

Another nifty thing I think is interesting is … I did a magical “save as” on the php file I’ve been using for this task and realized, wow, the crontab doesn’t need all of the html, css, jquery, etc. because that’s for me to see so I know the script worked. Not only do I know it worked but the crontab couldn’t care less so I stripped it all out of a new, dedicated file. I also rewrote (or, rather, wrote a new script based on) the script I’ve been using because part of the original added rows to a table that the crontab wouldn’t look at even if it existed. Because the crontab doesn’t have eyes. And doesn’t care.

Deeper. And stuff.

Just installed Composer.

Used that to install the latest version of PHPMailer.

Watching The Fugitive for the billionth time and was inspired to search for PHP jobs in Chicago. God, I’d love to live in Chicago. Almost as much as I love The Fugitive.

E is for Email Part 2

As it turns out, the CentOS 7 Cookbook has oodles of yummy information that Mastering does not including a simple up-front test to see if Postfix is already installed, running, and working. First, you send a local user a message

echo "this is a test" | sendmail username

and check the log to see if it worked:

tail -f /var/log/maillog

but that last command told me maillog doesn’t exist. Google told me, among other things, try restarting syslog. It turns out, that wasn’t even installed!

A quick

yum -y install rsyslog

fixed that …

well, I also …

http://www.itzgeek.com/how-tos/linux/centos-how-tos/setup-syslog-server-on-centos-7-rhel-7.html

but I got the stuff described in this

https://support.plesk.com/hc/en-us/articles/214528345-Mailserver-not-working-Warning-SASL-Connect-to-private-auth-failed

so I did the solutions provided in that and tried again

That didn’t work (see notes) so I uncommented that line and tried this instead (which maybe I should have tried first)

https://www.howtoforge.com/postfix-dovecot-warning-sasl-connect-to-private-auth-failed-no-such-file-or-directory

that totally didn’t work so I found and tried this

https://serverfault.com/questions/628966/dovecot-error-unknown-setting-unix-listener

and now dovecot works so I’ll try the test mail message again

totally worked! So now I’m going to send a message to my gmail account …

KICK-FREAKING-ASS! It worked! It went into my spam folder but it worked! And most of these tutes and such include stuff so your messages don’t go to spam and you don’t get blacklisted so I am on my way!

I Am So Ungrateful

Hours and hours today of stuff going right. Things installing easily and working perfectly. Updating huge chunks of code (without testing) without a problem.

Then, after about twelve hours … one little thing isn’t working … and I feel like throwing a tantrum.

Stupid SSL!

Update: Nevermind. It worked fine. It just look longer than my patience allowed for.

Making a Mail Server

Links so far:

https://hostpresto.com/community/tutorials/how-to-setup-an-email-server-on-centos7/

https://www.webhostinghero.com/how-to-configure-a-linux-server-to-send-emails/

https://www.digitalocean.com/community/tutorials/how-to-send-e-mail-alerts-on-a-centos-vps-for-system-monitoring

https://www.rosehosting.com/blog/how-to-set-up-a-mail-server-with-postfixadmin-on-centos-7/

PDFtk on CentOS7

Months ago, I tested it with positive results on either Mac OSX and/or Ubuntu 14.04 so now I’m gonna test it on the new CentOS7. If it doesn’t work, I’ll either wipe the VPS and install CentOS6 or Ubuntu 16.04. First, I have to remember how I used the templates I created to test it. Ugh.

Watching The Defenders on Netflix, btw. I wanna like Iron Fist so bad. Loved the comics. Iron Fist, that is, not the Defenders. Except for Defenders: Indefensible.

So, testing process is:

  1. Get form field info using dump_data_fields
  2. Export fdf from a filled-in form using generate_fdf
  3. Import that fdf data to fill in an empty version of that same form via fill_form

I have a PDF form that, filled out, looks like this:

AlbumForm

So, first, I need to get the names of the form fields.

pdftk AlbumFormEmpty.pdf dump_data_fields >AlbumForm.txt

That was successful. Yay. Result looks like this:

textOutputDump

Now, I’ll export the data from the filled-in form’s content — not normally a part of this process, but it’ll quickly get me the data and other shizzle I need for testing.

pdftk AlbumForm.pdf generate_fdf output AlbumData.fdf

Cool cool cool, that worked fine. It’s hideous, but I have it.

Later, I will/would write a PHP script to create such an fdf file out of data from an html form but for now, I’ll put that fdf back into a PDF form:

pdftk AlbumFormEmpty.pdf fill_form AlbumData.fdf output filled.pdf

Perfect. Awesome.

One of the places where I learned stuff:

https://www.sitepoint.com/filling-pdf-forms-pdftk-php/