#!/usr/bin/env python from timy import get_conn, get_recent_tasks, record_task # get the second most recent task, and start it up again name='' conn = get_conn() tasks = get_recent_tasks(conn, 2) try: current = tasks.next() pop = tasks.next() print "Stopping '%s' and restarting '%s'." % (current.name, pop.name) name = pop.name except: pass record_task(conn, name)