Running Cron Jobs on the Grid

from datetime import datetime, timedelta
import subprocess

def main():
    timestamp = datetime.now().isoformat()
    print 'Hello, World! It is currently %s.' % timestamp

def reschedule(**kwargs):
    when = datetime.now() + timedelta(**kwargs)
    timestamp = when.strftime('%Y:%m:%d:%H:%M')
    path = __file__
    command = 'bsub -b %(timestamp)s python %(path)s' % locals()
    subprocess.call(command, shell=True)

if __name__ == '__main__':
    reschedule(minutes=1)
    main()
Senior Statistician / Data Scientist

I enjoy statistics and programming.

Related