All in Good Time

17 02 2012

It seems like the energy around college students and the start-up scene has been really building lately. I’ve been talking to a lot of smart, driven young people and it’s really awesome. They go to Boston start-up events, they are starting their own companies, they are contributing to the community in a positive way. I say more power to them.

The only thing I do worry about is the gung-ho ones forcing out those at the fringe. Not everyone (me included) had any clue what they want to do while they are in college. Some people just want to study, party, and hang out with their friends (not necessarily in that order). And the last thing I want to happen is to alienate that group. Because they are smart too, and after a few years in another industry, learning amazing things, they could come back and start the next big company. For some, the 4 years after college are more formative than the time at college. If we make them feel like less-than now, like the only option is to be all-in or you’re out, we potentially lose their contribution.

For those folks who know what they want, and have passion around it, GO CRUSH IT. Learn everything you can, the world is your oyster, etc etc. Don’t despair if others don’t follow – the very fact that you are different makes you awesome. Be inclusive of those among us who spent college undecided. Maybe they don’t know who funded this company, or who runs that company. But in time, they could be changing the world alongside you. Respect their decision, and don’t give up hope for them :)





Syncing with Rsync/Cron in Mac OS

16 02 2012

With that mess complete, I could now SSH into my Mac Mini from the office using a command like the one below (replacing the X’s with your Time Capsule IP address):

I could now complete a successful rsync sync for the first time as well (command is all one line):

rsync -avz --progress /Users/jv/Desktop/forotherbooks/ jvmini@XXX.XX.X.X:/Users/jmini/Desktop/fromotherbooks

Step 2: Public Key Authentication

Hooray! Since I knew I wanted to end up being able to do this automatically, entering the password each time wasn’t going to be an option. We use public key authentication for a few things in the office, so I had an idea of getting that set up, but if you are new to that game, check out this guide. Here’s the run-down of the commands used:

ssh-keygen -t dsa
scp ~/.ssh/id_dsa.pub jvmini@XXX.XX.X.X:.ssh/authorized_keys
ssh jvmini

Step 3: Enter the Cron

Now I had sync set up and working, but the automated part was still missing. For that, I needed cron. Cron is a UNIX tool for scheduling jobs – pretty cool if you want to automate stuff and have it run on schedule. I didn’t have any experience with cron at all, so it took me a little while to get a handle on it. Basically, there are two parts: the script and the cron table.

The script I wrote wasn’t too complicated – essentially sync everything up, and the delete all the old files from the local directory.:

#!/bin/bash # This says which interpreter you want to run the script under (in this case bash)

RSYNC=/usr/bin/rsync # this tells the interpreter where to find rsync (run 'which rsync' to be sure)
SSH=ssh # find SSH in the same place as rsync
LPATH=/Users/jeff/Desktop/otherbooks/ # read: "where is the local computer path you wish to sync?"
RPATH=jeffmini:/Users/jeffmini/Desktop/fromotherbooks # read: "And what about the remote path?"

echo "Syncing and it feels so good" # I put this mostly for myself.

$RSYNC -avz --progress $LPATH $RPATH >> /tmp/output.txt # this is the rsync command, and then '>>' tells the interp to put the output into a text file (like a log)
cd $LPATH # CD into the local path
rm * # delete all the files that are left in there after the sync

I saved this under the title sync_books.sh and saved it for now in my Home directory.

Next was setting up the cron table. Cron table is a config file where your list of jobs are for executing. This step was a bit tricky, since the normal command

crontab -e

Wasn’t working properly for whatever reason. I blame Apple but that’s ok. I found a workaround, which is to use the editor Nano, rather than VIM, to edit the crontab file. In retrospect, this makes sense, since Apple has been tried deprecating the use of cron in favor of something called launchd. Anyway, here’s the command for opening the crontable in Nano:

EDITOR=nano crontab -e

This opened up the cron table, so I could add a new line to it. Cron tables (or at least my limited understanding of them) have syntax like so:

* * * * * command to be executed

The asterisks in this case stand for [min (0-59), hour (0-23), day (1-31), month (1-12), day of week (0-7, 0 and 7 are Sunday). A great tutorial for Cron table syntax is over at Admins Choice.

Step 4: Testing

Since I was setting up the cron job to run once a week (2am Sundays), I didn’t want to wait that long to make sure it worked. A one-line addition to my cron table file ran the cron script immediately:

*/1 * * * * /Users/jv/sync_books.sh

And then running a tail command in the terminal, to track updates to that “output.txt” file:

tail -f output.txt

And a minute later, voila! Syncing was complete! Now I can dump all the stuff I want to access on the Mac Mini (or archive) without clogging the network, or dumping it into the Time Machine abyss. Enjoy, and let me know if you have any questions!








Follow

Get every new post delivered to your Inbox.