Simple python scheduled tasks script that runs once daily I want to execute a python script daily and thereby want to schedules task as follows.

The idea is that the script will run once daily, and the script will then decide what tasks to be done today.

The reason is that I can't use cron or windows scheduled task on my environment.

The question is that, is there any better idea?

from datetime import datetime
import os

from sheduled_tasks import daily_task1, daily_task2, weekly_task, monthly_tasks

tasks = {} # or open from saved pickel file

schedule = {
    1: [daily_task1, daily_task2],
    7: [weekly_task],
    30: [monthly_tasks],
}

for delta, stasks in schedule.items():
    for task in stasks:
        name = task.__name__
        if ((task not in tasks) or
            (datetime.now() - tasks[name]).days &gt;= delta):
            task()
            tasks[task.name] = datetime.now().replace(hour=6)

# pickle tasks
You can get rid of doing any I/O and make your code cleaner in the process. 

from datetime import datetime
from sheduled_tasks import daily_task1, daily_task2, weekly_task, monthly_tasks

schedule = {
    1: [daily_task1, daily_task2],
    7: [weekly_task],
    30: [monthly_tasks],
}

# this could also be the date of first invocation, just change the timestamp
arbitrary_date = datetime.fromtimestamp(1234567890)
days_past = (datetime.now() - arbitrary_date).days

for delay, tasks in schedule.items():
     if days_past % delay == 0:
        [task() for task in tasks]