gcalcron » 2008
This is a script I created as a proof-of-concept to illustrate how simple technologies- ones that are available now, to anyone with a browser- can be used by people to control the space they inhabit. All you need is time to think creatively about what the technology around is capable of doing beyond what it’s doing now.
The script allows you to use Google Calendar as a frontend for cron-like scheduling on your Unix/Linux system. If that system is acting as a home server, you’ve suddenly gained an incredibly powerful administration tool that anyone can use to control and automate their environment. On this page, I talk about the technical aspects of the project, but in this post I talk more about the cool implications when looking at the bigger picture of design and interactive architecture.
How It Works
All you have to do is create a dedicated calendar in your Google Calendar and then create events as you see fit. When you create the events, include any commands you want executed at the time of the event in the event description. The script will check in every little while (half an hour default), and if there are events scheduled, will execute the associated commands.
You can have events execute at the end of an events as well, So, you could have an “Lights On” event where the coloured block actually shows when the light is on, rather than needing two events (one to turn lights on, and the other to turn them off). Much better than a list of cron jobs.
Quick Installation
Detailed instructions may be found in README in the tar file, but here is a super-simplified guide for installation under Ubuntu/Debian.
- Download the compressed files to your home directory.
- Open a terminal session and unpack the files with tar -xvf gcalcron-0.1.tar.gz followed by cd gcalcron-0.1Start the installation script with sudo ./setup.sh install
- Enter your Google account name, password and calendar ID when prompted. (The calendar ID is the ID of the calendar that will be checked for commands to run. You can find the ID of the calendar you want to use by looking at the “Calendar Address” field on the its setting page. The calendar settings pages can be found by clicking on “Settings”, selecting the “Calendars” tab.)
- The script will then install and set up everything for you. Once installed, you can run commands on your computer using GCal by simply creating an event in your automation calendar and listing any commands to be executed in the “Details” section of the event. If you want to have commands executed at the end of the event, list those commands after a “—”, as shown below.



For a more detailed explanation, instructions for other distros, instructions on how to set up a calendar specifically for automation and instructions for removal, see the README.
Notes
First off, it’s been a while since I’ve programmed and I taught myself some python just to make this thing. As such, I have made it available under the GPL 3.0 licence (more in the gzip), and I invite better people to adopt it and take it to the next level- more robust, more secure, tighter, all packaged up with better much installer. Please just credit me for the idea, and if you could include a link back to this page or the post page somewhere in the docs, I’d appreciate it.
Secondly, keep in mind that there is a security risk in exposing your computer to the net in this manner. With this script running, your computer will only be as safe as your Google account- anyone who get access to that will also be able to execute commands on your machine. The chances of someone hacking your account, noticing what you’re doing and deciding to be malicious about are probably pretty slim, but they’re there. You’ve been warned.
Finally, please note that I take no responsibility for anything that might happen as a result of running this script. You’re running this script as-is and I take no responsibility for any bad things that might happen. I’ve done my best with it and I’d like to be able to give you a better guarantee than that, but sadly I can’t.
Otherwise, enjoy.

Shame the script runs as root in the cronjob by default but otherwise very nice script, does a very good job.
Also your test case only works for the next noon if it is allready past noon in the day. – would probably be easier to say that in the README than let people guess
Cheers,
Brendan
Brilliant concept!
Very interesting concept, I really like the ingenuity.
Hey there,
This looks awesome. Unfortunately my initial tests have failed
I get some deprication warnings which I will assume arent a problem… but gcalcron doesnt seem to find (or activate?) the specified command.
I scheduled a job for 11am to finish at 11:30am sydney time. The cron job runs (and reports the deprication warnings) but the command either does not run or is not found. I tried to run the cron job from the command line with no luck. I have verified that the command works fine by itself (it just sends a teet)
here is the command from the description field:
is there a log somewhere?
any help appreciated
c.
This would be MUCH safer, and almost sane, if instead of putting shell commands directly into the calendar you used keywords so that the calendar was limited to a short list of allowed commands.
Visual cron is brilliant, though. Great idea!
[...] gcalcron This is a fun kind of "get your toes wet with linux" type of project that you could suggest to your "I want to learn about linux, but I’m not ready to junk my MacBook just yet" friends. The gist is that you "install" this cat’s .py script on your remote machine and this script acts as an interface between the box and a Google calendar you set up. You enter bash commands into the calendar entries and it uses the times you set with the gCal interface to tell cron when to pop them off. What it lacks in simplicity (by being an incredibly convoluted "work around" for spending 10 minutes with the cron man page) it makes up for in colorful, user-friendliness. [...]
Thank you, all, for the interest and kind comments. I’ve posted some general answers to your questions (re: security, mostly) in this post.
Specifically, though: Chris Shultz, the depreciation warnings are normal. If the command works and but the cron job doesn’t work from the command line, I’m guessing it’s a cron problem. There’s no logging, but try running gcalcron.py manually (that is, not via cron) with the verbose switch (-v) to see what’s happening behind the scenes. Chris Snyder: the prefix switch can be used to automatically limit the commands being run to a certain directory. However, I realized since this can easily be circumnavigated by using && followed by an arbitrary command. If I have time to work on this in the summer, I’ll address it.
If you’ve got any more questions, please do post again, or drop me a line.
Re: security
Note that instead of using the account username and password, you could use the “magic cookie” authentication method (see http://code.google.com/apis/calendar/data/1.0/developers_guide_python.html#AuthMagicCookie).
While this does still involve storing credentials “in the clear” on the user’s filesystem, the credentials only allow you to access a particular calendar, which seems far better than access to the entire account.
The changes required in the code are minimal; the examples in the documentation should be sufficient to get folks started.
To make life easier on the user, you can simply have them paste in their “private XML feed” URL and parse out the userid and magic cookie in your code.
[...] allow me to respond to a few of the comments about the project (left both on Lifehacker and the gCalCron project page right [...]