Signing a cron job in a google application

I went to the Google website on cron and it looks like I cannot set the cron task to run Mon-Fri every 10 minutes from 07:00 to 15:00. Therefore, I have 2 questions:

1) Can I start the cron task every day, and then not start it on Sat and Sun, and then resume again on Mon-Fri?

2) If I can’t do the first option, is there a way to automatically end the cron job?

I am doing this in Python. If this is not possible, is there a page I can turn to for help?

+4
source share
2 answers

Since you lose the ability to specify ranges after you set the days, I think the best option would be to provide time ( every 10 minutes from 07:00 to 15:00 ), and then check your script itself, which checks the current date to determine if it is a weekday or not. You can do this with something simple:

 >>> import datetime >>> today = datetime.datetime.today() >>> today.weekday() 1 

Where 0 = Monday, 1 = Tuesday, etc. If your cron confirms that the current day of the week was in (5, 6) , you can simply exit your program. One way to structure this can be to bind your cron to a simple function that checked the day β€” if your main function is called on a weekday; if not, it ends. There may be a better way, but what's the best I can think of right now :)

+4
source

A slightly cheaper alternative. CRON launch: every Monday, Tuesday, Wednesday, Saturday, Friday at 07:00 AM On this weekday, CRON launches a task (deferred or push), which will schedule the next task 10 minutes before 15:00.

0
source

Source: https://habr.com/ru/post/1441722/


All Articles