I have a Scheduler Job within Cloud Scheduler running to call a Cloud Function. Working as expected however I need to create multiple cron schedules for the same job, is this possible without recreating from scratch each one? There doesn't seem to be a Copy function.
Use Case:
Schedule 1 - Every 15 minutes Monday - Thursday
Schedule 2 - Every 15 minutes Friday SoD till Friday 22:00PM
Schedule 3 - Every 15 minutes Sunday 22:00PM till Sunday EoD
How can I achieve this, or do I just need to recreate all the schedules from scratch?
Posting this as a Community Wiki as it's based on #GuillaumeBlaquiere and #Al-dann comments.
At this point you going to need to recreate all of those schedules from scratch, however, you can automate the creation of new Jobs with a script, either with gcloud or terraform. This will make duplication, creation and deletion of Jobs easier and quicker as well as allow you to version it.
Related
I'm trying to automate and streamline a daily process that I've been babysitting for several months. Because our upstream pipeline can and may be delayed for several hours, I've created a package that checks the pipeline every 30 minutes. Once the pipeline completes, I manually perform steps 2 - 6.
I have stored procedures that will execute steps 3 - 6, but each step can only run once per day and only after step 2 completes.
Step 6 only after step 5.
In the attached image.
Can someone show me how to disable a task based on step 1 value?
I would like to delay deletion of data from the database. I am using MySQL, nest.js. I heard that CRON is what I need. I want to delete the entry in a week. Can you help me with this? CRON is what I need, or i need to use something another?
A cron job (or at in Windows) or a MySQL EVENT can be created to periodically check for something and take action. The resolution is only 1 minute.
If you need a very precise resolution, another technique would be required. For example, if you don't want to show a user something that is more than 1 week old to the second, then simply exclude that from the SELECT. That is add something like this to the WHERE: AND created_date >= NOW() - INTERVAL 7 DAY.
Doing the above gives you the freedom to schedule the actual DELETE for only, say, once a day -- rather than pounding on the database only to usually find nothing to do.
If you do choose to "pound on the database", be aware of the following problem. If one instance of the deleter script is running for a long time (for any of a number of reasons), it might not be finished before the next copy comes along. In some situations these scripts can stumple over each other to the extent of effectively "crashing" the server.
That leads to another solution -- a single script that runs forever. It has a simple loop:
Do the actions needed (deleting old rows)
Sleep 1 -- or 10 or 60 or whatever -- this is to be a "nice guy" and not "pound on the system".
The only tricky part is making sure that starts up after any server restart or crash of the script.
You can configure a cronjob to periodically delete it.
There are several ways to configure a cron job.
You can write a shell script that periodically deletes entities in the db using linux crontab, or you can configure an application that provides cronjobs such as jenkins or airflow.
AWS lambda also provides cronjob.
Using crontab provided by nestjs seems to be the simplest to solve the problem.
See this link
https://docs.nestjs.com/techniques/task-scheduling
If I have hundreds of triggers set to work on a specific day of the week within the same hour time frame (lets say Monday between 8 am to 9 am) - will they be executed in the way that will burden the least on the server?
If not - according to which consideration the execution time will be determine?
Is there a limtation of amount of triggers in an hour/day? What is it? (in Quotas for Google Services I found only a Triggers total runtime).
Thanks!
So here is a thing, I have some lawyer app, and he needs to set reminder for some case, that reminder could be tomorrow, next week, next month idk. I was thinking about using node-cron, thing is i dont know what will happen when my app restarts, I assume it will crash all my reminders, and the second thing is how much will I load my server if i got to much reminders, OR do u have some other advice for this solution, maybe something with setInterval and run it every hour or something like that?
node-cron is used to run code as you would with normal cron, but in JS :)
So even if your code is crushed and restarted it will look at time set by you to execute some code and will not crush reminders.
For example if you run some code with cron condition 0 0 1 * *, which means every month on 1st date at 00:00.
That means that even if your app is crushed at 15th of month and restarted at 20th of month, it will run your job at 1st of next month at 00:00.
Between for automatically restarting your app you can use forever or pm2 packages from NPM
Now about this question.
how much will I load my server if i got to much reminders
I don't think it will load your server. node-cron internally uses setInterval, which is not CPU consuming, so go and run your crons without fear.
I'm looking for a way to be able to set my app to launch and carry out certain functions depending on the time and day of week. The app needs to be able to set the time and days of week, then run a specific function depending on that time and date. For instance if I set the app to run 1 function 12:00pm every Saturday, and another 3:00pm every Sunday, they can be processed in the background somehow. Essentially I want it to run like a scheduled background, where I might run an incremental backup during the week and a full backup on the weekend.
I've searched all over and can't seem to find any leads.
Any help would be greatly appreciated!
Thanks.
Take a look at Local Notifications: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194