def main(infile):
    rfile = open(pjs.running_file, 'w')
    rfile.close()
    jobs=1
    while (jobs == 1 and not os.path.exists(pjs.pause_file)):
        newjob = get_next_job(infile)
        pjs.remake_list(infile)
        if newjob[0] != '' or newjob[1] != '':
            jobs = 1
            if newjob[1] != '':
                logger.info('\tStarting job *' + newjob[0] + '*')
                echojob = launchjob(newjob)
            # if os.path.exists(newjob[1]):
            #     echojob = launchjob(newjob)
            # elif newjob[1] != '':
            #     logger.error('\tUnable to find script ' + newjob[1] 
            #                  + ' for job *' + newjob[0]+ '*')
            else:
                logger.error('\tJob *' + newjob[0] + '* has an empty command')                
        else:
            # print 'No jobs found at ' + str(time.asctime())
            jobs = 0
        pjs.remake_list(infile, True)

    os.remove(pjs.running_file)
    return 0