I Have Made Fire!

Crontab window in editorOver the last 9 years or so, Bart Busschots has been teaching you and me to be geekier and more technical through his session in Chit Chat Across the Pond. First, it was random bits of knowledge but in the last few years he’s gotten much more structured about it, bringing us Taming the Terminal and now Programming By Stealth.

I have to confess (and you may have figured this out on your own), I don’t always understand everything he teaches me. Sometimes I understand in the moment, but when I go to apply what he’s taught me, I’m immediately baffled.A while ago, I moved podfeet.com to a Virtual Private Server. Bluehost kind of talked me into it. It didn’t cost a lot more money than the shared server I was on and I knew it would give us all much greater performance for the site. Nobody accesses podfeet.com more often than me, so it was really a present to me as much as to you.

There was one thing that didn’t entirely dawn on me when I agreed to this. On a Virtual Private Server, I am the system administrator! They do some stuff for me, but most of what I took for granted is on my plate. I called Bart in a panic when I found this out, and asked him if he’d officially be my sys admin. He suggested a better idea. Instead of him doing it for me, he wanted to teach me to do it myself!

When I was working I had 150 system administrators working for me. I know a few of them listen to this show and they are falling out of their chairs with hysterical laughter at this idea. I’m looking at you, Keith. I’ve come a long way but I have to be on their side that this is silly talk, but since Bart was willing to do it, I had to jump at the opportunity to learn even more.

This week we worked on some scripts that he wrote that he said we could configure to back up my server to my local drive on our Mac mini. In August of 2015, Bart gave us an introduction to JSON and explained that it’s very useful to create configuration files that can be fed into programs. When Bart created his backup script, instead of making multiple versions for all the servers he managed, he used JSON to make configuration files for the peculiarities of each server. I was so excited that I immediately understood why he used JSON.

During our last few sessions he let me drive while he watched on Skype. I created a public/private key pair so we could talk to the server from the Mac mini, then we modified the JSON configuration file and got everything working. Now every single day at 2 in the morning, a database dump occurs up on podfeet.com, and then the Mac mini pulls that file down. Using rsync, it also pulls down a copy of all of the files associated with podfeet.com. The files are, in my case, mostly images I upload for the blog posts, while the database itself contains all the words that I’ve typed over the last 11 years, the theme for displaying the content, and other bits and bobs like users and plugins.

This was all going swimmingly, but today I was looking at the directory structure on the Mac mini and I saw something I didn’t quite like. We created a log file to let us know if the backups had worked properly. It’s called, quite imaginatively, backup.log. We stored it at the top level of my user account. We also created a directory at the top level of my user account called podfeet_backups, and that’s where the actual backups get plopped, all into neat little daily folders.

I didn’t like having that log file sitting out in the open where Steve or I might accidentally throw it away or clean it up in some fashion that would make it break. I knew I could simply drag it into the podfeet_backups folder, but that would probably confuse the backup script, or at the very least I’d end up with two files.

You’ll never believe what happened next! Sorry, channeling Buzz Feed there for a minute. I noodled around a bit and looked at the backup script itself, but it’s got a lot of stuff in it Bart hasn’t told me about yet. I thought maybe the JSON configuration file would point to where the log file would be written but it wasn’t in there either. It did have the location of the folders of content that were backed up but not the log file.

Then I reached back in my brain to recall how we actually make this backup script go and I remembered we’re using a cron job. Cron is a utility that can be set to run in the background at regular intervals. Crontab is the text file where you define those things that you want to run, and it also tells cron when to run them.

I whipped open my notes from the last time we worked on it (I keep them all in Together from reinventedsoftware.com) and found what I was looking for. In the crontab we told it what time to run (using days, hours, minutes, and seconds), we told it the name of the script to run, we told it the JSON configuration file to use, and the very last bit was where to spit out the log file!

Now all I had to do was remember how to edit that crontab. This next part is why I entitled this segment, “I have made fire!” For as long as I’ve been able to spell UNIX, people have told me, “Just look at the man pages to figure out how to use a command.” And not once, in the 20 years or so people have been saying this to me, have I figured out how to do what I wanted to do from the man pages. Until today. Right there in the man pages, it said to write crontab and follow that by -e and I’d be in an editor! I didn’t know what editor I’d be in but I hoped I could guess.

I think I ended up in vi, which is an editor I learned to use in the late 1800s. I saw where I wanted to insert the directory name to push the file down a level. I arrowed over, closed my eyes, and tapped the “i” key. At the bottom of the file, I was rewarded with the word “INSERT”. Yay! I typed in the folder name. Now I had to remember how to get out AND save the file. Scraping back in the memory banks (from the last time Bart and I mucked in this file) I typed escape, then colon wq for write, and then quit. The file saved and it worked!!!

I know this is a silly little example, but it makes me so very happy to have been able to do such a simple little procedure, ALL BY MYSELF.

11 thoughts on “I Have Made Fire!

  1. MacLurker - March 30, 2016

    It’s a not so silly example and you figured it all out. I could not have done better myself. You should never be intimidated by man pages again.

  2. Daniel L. - March 30, 2016

    I must do this. Because I think I’m my own sysadmin right now too, and I’m about to mostly self-design my site that resides on private server, yet I haven’t the foggiest (another expression I learned from the 1800s) about how to publish?/upload? (wow, the sysadmins think, he is an idiot) cause I don’t even know what verb I need to use.

  3. Sandy - March 30, 2016

    Congratulations, Allison! But I’m really surprised; I could have sworn I was older than you, but if you were computing in the late 1800s, you must be *way* older than me. 😉

  4. Bob Goodrich - March 30, 2016

    Congrats! Didn’t understand what the heck you did, but no matter.

  5. Gary (SeniorGeek) Fisher - March 30, 2016

    You’ve evoked my years as a Unix sysadmin in the early ’90s. As part of my job I occasionally need to edit a file on a Linux host, and I still use vi because 1) the command structure is still stored in muscle memory and 2) I know vi will always be available, where other editors may or may not be installed.

    Same reason I used to use edlin in the bad old days of DOS.

    Thanks for the trip down memory lane.

  6. Jim Sewell - March 31, 2016

    Now you have discovered the crack that drives many times of us who do this and similar jobs for a living. The rush from seeing a computer do what you want instead of vice versa is awesome. Well done Allison!

  7. Bart Busschots - March 31, 2016

    Yay 🙂

    I particularly like the deliberate and analytical path from problem to solution. Give an engineer some new tools and there’s no stopping them!

  8. Timothy McCoy - April 1, 2016

    Really. congrats on your effort and success! I recently started investing time in learning/using the ‘Atom’ editor because of Bart’s high praise. (Much easier to use than vi) Task for the student: Visit the crontab man pages again (-e) to preset and use your preferred text editor in crontab (and most other text editing needs). Have fun in *n*x land!

  9. Allison - April 1, 2016

    Ooh! Cool idea, Tim! I’ll mention to Bart. We’re trying to use built-in apps available to all for- tutorials but maybe on my own I could sneak out and try it.

  10. […] a month ago, Allison wrote a blog post entitled “I have made fire!” which briefly chronicled how she had imagined a change she wanted to make to a scripted, […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top