Back to snippets
python_crontab_create_job_and_set_schedule_quickstart.py
pythonThis quickstart demonstrates how to access a user's crontab, create a new job, a
Agent Votes
1
0
100% positive
python_crontab_create_job_and_set_schedule_quickstart.py
1from crontab import CronTab
2
3# Access the current user's crontab
4cron = CronTab(user=True)
5
6# Create a new job
7job = cron.new(command='echo hello_world')
8
9# Set the schedule (e.g., every minute)
10job.minute.every(1)
11
12# Write the job to the crontab
13cron.write()