How to run cron job at users time zone using spring boot - spring-boot

We have users from all over the world using application. Our requirement is to run cron job at 12 am daily at users time zone and only for users in that time zone.
How can this be achieved using spring boot??

In #Scheduled notation you can pass Zone but only single time zone so you need to manage it with custom logic.
I believe your user record has included with time zone so to order to achieve it, You will need to set the cron job to run every half an hour(cover all time zones to include + 1/2 an hour), Get all timezones which has midnight then get users in those time zones to run logic for them..

You have to convert all the cron job times (12 am) in the user's time zones, to the equivalent times on your server, by adding or subtracting hours to compensate for the time difference. With the server time zone equivalent of the cron job times, you can schedule all the cron jobs.

Related

Aggregate timeseries data over various timeframes

I have a question about how to aggregate time series data that is coming into DynamoDB.
Currently energy usage data is coming into DynamoDB every 30 seconds per device. The devices are also spread across many timezones.
I want to show the aggregate energy usage over one hour, one day, one month, and one year.
I know one way that I can do it is run a Lambda on a 1 hour cron job that takes all of the readings for the previous hour and adds them all together and then records that in a different table in.
At the same time in that cron job the Lambda can check if any devices timezones just had their day end, and if so batch up the previous 24 hours for into a single day reading.
The same goes for month, and year.
But something tells me there is a another, better, way to do all this (probably using some otherAWS service which I am not thinking of)
Instead of a cron job, you can use dynamoDB streams.
In this case, when a record comes into your data collection table, it can kick off a lambda function that updates your aggregate tables. That will allow you to get more timely updates into the aggregate tables. The logic for what hour/day/month/year your record gets aggregated should be in that lambda.
Also, I’d use a cloud watch event instead of cron...

Add cron entry to XAMPP server

I am using Laravel 5.4 on Windows. In the documentation, it does not say how to add cron entries to server. I searched on YouTube, but didn't get any useful video. I need to learn how to add cron entries both to localhost and cPanel.
First of all you can add cron only in Server Not for localhost
To add cron in cPanel follow the steps below
Step1:-
First create a cron function to which the server is going to hit,
and get the Full path like
http://fullpath
Step2:-
Then got to cron jobs in cpanel and set the time when the cron will hit that route.
To set the time you have to follow this
Minutes represents the minutes of a given hour, 0-59 respectively.
Hours represents the hours of a given day, 0-23 respectively.
Days represents the days of a given month, 1-31 respectively.
Months represents the months of a given year, 1-12 respectively.
Day of the Week represents the day of the week, Sunday through Saturday, numerically, as 0-6 respectively.
Like this
Step3:-
Then Write the cron comand like
curl http://fullpath
Like this:-
This above cron job is set for 1 sec.That means the cron will hit that route in every one sec.
Like this you can set your cron on cPanel.

Oracle Scheduler run time time-zone dependent?

If I change the time zone of my local machine, will it affect the Oracle Scheduler's next run time??
schedule jobs run from the time on the system clock of the server, so changing the timezone changes the system clock and therefore the next scheduled time
From my experience, Oracle scheduler takes the timezone from the session, unless you specify a start date (TIMESTAMP WITH TIME ZONE). If you want to change the timezone of a scheduled job, use dbms_scheduler.set_attribute and give a new start_date with the timezone you want. Check by looking at the next run date in DBA_SCHEDULER_JOBS, which is also of type TIMESTAMP WITH TIME ZONE.

Scheduling Monthly job using oozie coordinator

Can you please help me with, what can be used to for scheduling an oozie coordinator job to execute on first Monday of every month.
I know we have a frequency parameter that can be set as ${coord:months(1)} . But this will not allow me to schedule the jobs on a particular day of a particular week of a month. Hope I am not complicating the question here.
Any help is strongly appreciated.
Thanks,
Syed
You unfortunately cannot schedule in the specific manner you are looking for. As you already note, you can run on a monthly basis - i.e. the 5th day of each month, but you are not be able to control the Day of the Week other than for the first materialization.
A possible work around this would be to run your coordinator on a weekly basis, to materialize on the Monday and then have a custom Java Action as your first step in the workflow that will throw an exception if it's not the first day of the month.
A downside of this approach is that you'll see 4 or so failures per month in the job list for the coordinator, but at least it will give you the behaviour you're looking for.

API to find the number of instances run by hour - AWS

I am looking for API that can return number of instances that run during the course of the day for each of the hour.
If it was my task, I would create a php script that runs in cron job every hour and record EC2 instances information (Running number of instances a part of that) in the database.
Then just query the database to with the right parameters.

Resources