Hybris: how to schedule cornjob to work from 7am to 11pm? - jobs

How to schedule cron job in Hybris, so that it triggers every hour between 7 am and 11 pm?

You can make use of a cron expression generator :
https://www.freeformatter.com/cron-expression-generator-quartz.html
Expression : 0 0 7-11 ? * * *

Related

Convert decimal minutes into Minutes:Seconds?

Anyone know if there's a function to convert decimal minutes into Minutes:Seconds in
Snowflake?
For example:
input: 8.5 (as in 8.5 minutes)
output: 8:30 (as in 8 minutes 30 seconds)
Source: https://twitter.com/jasongrahn/status/1420768503133401095
Using TIMEADD to add number of seconds since midnight:
SELECT TIMEADD(second, 8.5 * 60, '00:00'::TIME) AS res;
--arg
Output:
RES
00:08:30
Putting the two excellent solutions already provided together:
SELECT TIME_FROM_PARTS(0,0,8.5*60)
This is nice because it's straight SQL - UDF's may not perform as quick
TIME_FROM_PARTS allows you to pass not just seconds but also minutes,nanoseconds etc.
If you go over 1 day just switch to TIMESTAMP_FROM_PARTS
Below I pass in 5.1 million nanoseconds returning 1 month, 28 days and 40 minutes. This demonstrates the extendibility of the built in functions that can always be used elegantly.
Just build a date from parts, and separate the decimals from the integer minutes.
You can create a SQL UDF for convenience:
create function from_decimal_minutes(minutes float)
returns time
as $$
time_from_parts(0, floor(minutes), 60*(minutes-floor(minutes)))
$$
;
select from_decimal_minutes(8.5);
-- 00:08:30
;

Find the difference between current time and last failure in grafana?

I have a dashboard built up where i am able to fetch the last failure time through conditions such as (total_failed<>0) but that gives me output as time like 10:20 but I need to have the Output generated in form of "last failed 30 mins ago " by calculating (current time - failure time ) so that. I can show that in dashboard .
Query Given -
SELECT
end_time AS "time",
(total_failed::integer)
FROM job
where
total_failed<>'0'
GROUP BY end_time,total_failed
Let me know if anyone can help me writing that sql or representation of that dashboard .
Perhaps this combination of age, extract and a CTE is what you need:
WITH data AS (
SELECT age(clock_timestamp(), end_time) AS ago,
total_failed::integer AS fail_count
FROM job
WHERE ...
)
SELECT extract(minutes FROM ago)
+ 60 * extract(hours FROM ago) AS minutes_passed,
fail_count
FROM data;

What will be the cron expression for every 2 hour on cronos? I am using 0 */2 * * * but its not working

I am using 0 */2 * * * cron expression for every 2 hours but its not working. I am using cronos for cron job. So what will be the cron expression for every 2 hour on cronos?

Automating the scheduletable of jobs

There is a table where we had jobnames and there tsrat time stored I want to run a script which will run and check if any jobdidnot start by its scheduletime.
Actually basically I want to create a script which will call my sql query
For example table name is SCHEDULE..column JOBNAME and COLUMN SCHEDULE_TIME
and lets take one example as JObname X should start by 10:30 AM
Thank you ....Please help
Assuming the table that holds what jobs were run and when is called "JOBLOG" and the actual time each job is run is stored in a column called "ACTUAL_TIME" on that table, you would run something like the following:
This will show jobs that started after they were scheduled, or jobs that were scheduled to run 10 or more minutes ago, but which have not yet started (in the latter case, the third column will be null)
select s.jobname, s.schedule_time, l.actual_time
from schedule s
left join joblog l
on s.jobname = l.jobname
where l.actual_time > s.schedule_time
or (l.actual_time is null
and (sysdate - s.schedule_time) * 24 * 60 >= 10)

Restrict SQL results by time, MySQL

I have a table containing events which happen in my application like people logging in and people changing settings.
They have a date/time against the event in the following format:
2010-01-29 10:27:29
Is it possible to use SQL to select the events that have only happened in the last 5 mins?
So if the date/time was 2010-01-29 10:27:29 it would only select the events that happened between 10:27:29 and 10:22:29?
Cheers
Eef
SELECT foo FROM bar WHERE event_time > DATE_SUB(NOW(), INTERVAL 5 MINUTES)
(Not sure if it's minutes or minute)
WHERE my_timestamp < DATE_SUB(now(), INTERVAL 5 MINUTE)
You should provide table and column names to make it easy for us to answer your question.
You can write SQL as
SELECT *
FROM Table
WHERE DateTimeColumnName <= '2010/01/29 10:27:29'
AND DateTimeColumnName >= '2010/01/29 10:22:29'
or you can use BETWEEN
SELECT *
FROM Table
WHERE DateTimeColumnName BETWEEN '2010/01/29 10:22:29' AND '2010/01/29 10:27:29'
Now see if there are datetime functions in MySQL to do a Date Math so just pass a single date stamp, and do the math to subtract 5 min from it and use it as the second parameter in the between clause.