My First Cron Job(s)

Learning from this great “Automated Tasks” page at

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.


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:


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:


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:

I Feel the Need for FTP

Learning Vi. Comfortable with it. No longer fear it. But I’d much rather download files, edit them in just about anything other than the Terminal, and upload them.

FTP worked fine at first.

Then it let me download but not upload stuff (and FileZilla did some crazy-looking stuff while trying).

Now I can’t connect at all.

I’m sure it’s fine. I’m sure all the changes I’ve made have something (or everything) to do with it.

The top two links look the most promising.

This next one includes SSL/TLS stuff

This is about FTP and (blech) WordPress.

CentOS Does Things Differently

BTW, FYI, all of these new posts are living documents as I learn. Do not assume they are complete or comprehensive.

Thing #1

CWP (or, CentOS Web Panel) is a free alternative to, for example, cPanel. It looks very nice. I’m waiting to install and try it because I want to learn all the command line methods for doing all of this. My new host telling me that I must do everything via command line and do it myself when neither is true most significantly when something absolutely had to be done using the SolusVM and/or they say they won’t do something/anything and they do crap without telling me that overrides something I’ve already done means I have to be able to find do and fix things with no other tools or assistance. Also, it means I can follow and understand all those MySQL tutes that do everything via command line.

My wife says I should pay someone to take care of all this frustrating and confusing stuff that is slowing me down but, I tell her, then I’m not learning and I’m learning and doing all of this so that, someday, I can get a real job and paying someone else doesn’t meet that need.

Thing #2

CentOS uses yum not apt-get. And those two, so far, seem to work very differently.

Thing #3

Matt S, the world’s greatest (well, if not the world’s, definitely A2Hosting‘s greatest) tech support angel says Ubuntu is easier to use. I, however, must use it because the little library/script thing that is crucial to my web app needs CentOS.

Libraries Roxor My Soxor

Now that it seems I’m finished arguing with support peeps at my new host, things are going much more smoothly. Well, they’re going smoothly — period.

It also seems that I’ve mastered using Overdrive to borrow eBooks via my local library. Just downloaded the following to my Kindle where I’ll have them for the next 21 days:

  • CentOS 7 Linux Server Cookbook 2nd Edition by Pelz & Hobson
  • Mastering CentOS 7 Linux Server by Bhaskarjyoti Roy


Seriously, if your library doesn’t have recent editions, recent topics, or the product/OS/whatever you need, check out their eBooks. You don’t even need a tablet or anything, you can read them online. You can get the Kindle app on any Android tablet or iPad (or phone) — you don’t have to use a Kindle.

LPT: Check the books out using a desktop browser then read them on your mobile device. Trying to use your library’s site and Overdrive on a tablet or phone will make you become a clocktower shooter in a few short minutes.

Now I can continue my mastering of my domain while my son is in youth group at churchy church tonight. We moved to the country so driving back home and then back into the big city isn’t an option I’m taking. Find a new church? No. The area to which we moved has a lot of Confederate flags hanging about. There’s a big church at the main intersection (near the feed store) and it has a whole separate building for their gift shop. They sell:

  • Sunday School supplies
  • Guns
  • Bibles
  • Knives

So, we’re still making the drive into town for our fellowship and worship and whatnot. It would be nice if they had stuff for adults on Sunday nights but our church has it’s own quirks that are frustrating. Great pastor though. Totally awesome.