how to set up a job to have two run windows? Please see sample job below. - autosys

How can I set up a Autosys job to run at two separate intervals? Please see the sample job below.
This job needs to run between 00:06 - 00:56 and then again between 04:06 - 04:56. The start_mins can be same.

You can't. Your example requires two jobs. One with run_window: 00:06 - 00:56 and the second with run_window: 04:06 - 04:56.
Syntax This attribute has the following format: run_window:
"time-time" time-time Defines the interval during which a job may
start in the format "hh:mm-hh:mm", where hh denotes hours (in 24-hour
format) and mm denotes minutes. You must enclose the interval in
quotation marks (") and separate the beginning and ending times with a
hyphen (-). The specified interval can overlap midnight, but cannot
encompass more than 24 hours. Limits: Up to 20 alphanumeric characters

If you are running the Job exactly once between 00:06 - 00:56 and 04:06 - 04:56 time frames you can try to set starttime as 00.06 and 04.06 and set
max_run_alarm: 50

Related

TeradataSQL: Time to String, Add to Date and Compare to Another Time and Data

I'm trying to figure out the cleanest way to do a comparison in Teradata SQL Assistant. I have the scheduled start date (TimeStamp), the Schedule start time (varchar), actual start and end times (TimeStamp). I need to consolidate the scheduled start date and time and be able to compare it to the actual start and end date and time without modifying the original data (because it's not mine). I realize that the Scheduled Start Time [SST] is in a 24 hour time format with a AM/PM suffix, but like I said before, I can't change that.
I tried to do select cast(substr(scheduled_start_date,1,5) as TIMESTAMP(0)) from DB.TBL but am getting the "Invalid timestamp" error. There is example table data below.
Sch Start Date Sch Start Time Actual Start Actual End
09/11/2017 00:00:00 11:30 AM 09/11/2017 11:34:16 09/11/2017 11:58:00
05/26/2017 00:00:00 15:30 PM 05/26/2017 15:40:00 05/26/2017 15:55:15
11/06/2017 00:00:00 19:30 PM 11/06/2017 21:25:00 11/06/2017 21:45:00
Thanks!
You need to cast the schedule start time as an Interval, then you can easily add it to the start date:
scheduled_start_date
+ Cast(Substr(scheduled_start_time, 1,5) AS INTERVAL HOUR TO MINUTE)
A start date which is a timestamp seems to indicate this was ported from Oracle/SQL Server?
And a 24 hour time format with a AM/PM suffix is also quite strange.
A couple things to try:
Convert the separate Scheduled Date and Scheduled Time fields into strings, concatenate them, and feed that into a TIMESTAMP CAST. Something like:
SELECT
CAST(CAST(Scheduled_Date AS DATE) AS VARCHAR(25)) AS Date_String,
CAST(CAST(Scheduled_Time AS TIME FORMAT 'HH:MM BB') AS VARCHAR(25)) AS Time_String,
CAST(TRIM(Date_String) || ' ' || TRIM(Time_String) AS TIMESTAMP(0)) AS MyTimestamp
Cast the Scheduled Time field as a TIME data type. Cast the Scheduled Date field as a DATE data type. Then somehow combine the two into a TIMESTAMP field -- either with a CAST or some kind of timestamp constructor function (not sure if this is possible)
Option 1 should work for sure as long as you properly format the strings. Try to avoid using SUBSTRING and instead use FORMAT to cast as DATE/TIME fields. Not sure about Option 2. Take a look at these link for how to format DATE/TIME fields using the FORMAT clause:
https://www.info.teradata.com/HTMLPubs/DB_TTU_16_00/index.html#page/SQL_Reference%2FB035-1143-160K%2Fmuq1472241377538.html%23wwID0EPHKR
https://www.info.teradata.com/HTMLPubs/DB_TTU_16_00/index.html#page/SQL_Reference/B035-1143-160K/cmy1472241389785.html
Sorry, I don't have access to a TD system to test it out. Let me know if you have any luck.

Identifying a DateTime formatting convention

I'm working on a program (we'll call this the PostProcessor) that applies some post-processing to the output of another, closed-source program (we'll call this the Original program. Part of the post-processing involves re-calculating a DateTime value and outputting it in the same format as the original.
For example, the Original may output:
03 : 15 : 30 [h:min:s]
The PostProcessor calculates that the actual time should be 4 hours, 20 minutes and 10 seconds and should output:
04 : 20 : 10 [h:min:s]
The "nice" thing is, despite being mostly a black-box, Original program has some configuration settings. Buried deep within these settings is a string value TimeOutputFormat, which PostProcessor can read.
In the above examples, the TimeOutputFormat string was:
%#H : %M : %S [h:min:s]
Another valid format string I've encountered is:
%q2 min
Which outputs the total minutes to 2 decimal places.
From fiddling around, I've also found the %c format string, which outputs in the form:
1/1/1970 03:15:30 AM
which confirms that the Original program is storing these DateTime values in some form of Unix time object.
What I would like to find out is what formatting system is being used, so I can implement it in my PostProcessor. I'm hoping it's a somewhat standard format since I don't have any documentation. The black-box Original program uses a mixture of Visual C++, .NET, and Python modules (and possibly other technologies I'm not aware of).
Here's a catalog of what I've found so far.
# before the letter (i.e. %#d) pads the value with leading 0's
# removes padding from a value %d -> 01 but %#d -> 1
a digit after the letter (i.e. `%d3') displays decimal digits (if the value has them)
Known formatting strings (from trial/error)
%H - Hour component (not total hours, just the hour component)
%M - Minute component
%S - Second component
%a - Day of week (three letter abbrev.)
%b - Month (three letter abbrev.)
%c - Full date (m/d/yyyy HH:MM AM/PM)
%d - Not sure (outputs "01") (guessing day?)
%e-i Not defined
%j - Not sure (outputs "001") (guessing day out of 365?)
%k-l Not defined
%m - Not sure (outputs "01") (guessing month?)
%q - Total minutes
%p - AM/PM
If anyone can identify this formatting system, I'd greatly appreciate it. I'm going to continue to catalog it for my own use, but it would be nice to have some original documentation if it happens to be a publicly available (and hopefully well-documented) system.

Convert unix timestamp to human readable time in mysql

We are trying to convert unix timestamp to human readable time when running mysql commands.
For the unix date we have this working command
select FROM_UNIXTIME(registered) AS "ResolutionDateLine" from tickets
which gives us an readable date like
2012-12-03 09:41:00
But we do also have unix timestamp "seconds" that we need to convert, using the same line as above we get 1970-01-01 01:00:00 but the actual value should be 89 days, 23 hours, 22 minutes and 34 seconds.
Then we tried
select FROM_UNIXTIME(firstresponsetime, "%dd, %Hh, %Im") AS "Response" from tickets
with this result:
01d, 00h, 12m
Does anyone know how to convert this correctly in the mysql command?
Use SEC_TO_TIME (http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_sec-to-time) to convert a duration in seconds to a HH:mm:ss notation.
select sec_to_time(3500);
results in
00:58:20
Your will be like
select FROM_UNIXTIME(firstresponsetime, '%d-%m-%Y %H:%i:%s') AS Response from tickets
or you can customize it by change second parameter.
for more please check below link:-
http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_from-unixtime

Move sets of files with date encoded names

I have a set of files that have dates in them.
lets call them:
a20120528_120001.log
b20120528_120003.log
(name)(year)(month)(day)_(hour)(minute)(second).log
It is easy enough to move these two files simultaneously by doing:
mv *20120528_12* file/
But now I have a situation where I want to move several hours worth of files in the same day ie:
a20120528_120001.log
b20120528_120003.log
a20120528_130001.log
b20120528_130003.log
a20120528_140001.log
b20120528_140003.log
Now if i wanted to transfer all of them i could just do the day:
mv *20120528* file/
but what can I do if I only want to move hours 12 and 13, but exclude 14.
Please note this will need to be generic enough that i can input the date, because this will extend to be used across multiple days where there are 24 logs per day and several (between 3-8) will be excluded from each day.
How would I do this?
You can use ranges:
mv *20120528_1[23]* file/
For excluding everything from 3-8, go with the slightly more complicated:
mv *20120528_{0[0-29],[12]*}*
[0-29] breaks down to the range 0-2 and 9.
{A,B} expands to A or B.
This is a good question because in Bash, filename expansion uses only *, ?, and [. So you can deal with hours 12 and 13 only with the following:
[ab]20??????_1[23]????.log
Note that this takes you up to the year 2099 only; adjust accordingly if that bothers you.
But if you need a general range of values, you will need multiple commands. If you have hours 00 through 23 and you want to exclude 03 through 08, I think you will need the following:
[ab]20??????_0[0129]????.log
[ab]20??????_1?????.log
[ab]20??????_2[0123]????.log
Of course you can also write a script to generate the proper patterns, using something more complex than filename globbing. Not sure if you need that much complexity, though.
you may use THIS BATCH FILE
for /R SOURCEPATH %%f in (20120528_12,20120528_13) do MOVE "%%f" DESTINATION PATH

Get Current date in epoch from Unix shell script

How to get the current date value in epoch i.e., number of days elapsed since 1970-1-1. I need solution in unix shell script.
The Unix Date command will display in epoch time
the command is
date +"%s"
https://linux.die.net/man/1/date
Edit: Some people have observed you asked for days, so it's the result of that command divided by 86,400
Update: The answer previously posted here linked to a custom script that is no longer available, solely because the OP indicated that date +'%s' didn't work for him. Please see UberAlex' answer and cadrian's answer for proper solutions. In short:
For the number of seconds since the Unix epoch use date(1) as follows:
date +'%s'
For the number of days since the Unix epoch divide the result by the number of seconds in a day (mind the double parentheses!):
echo $(($(date +%s) / 60 / 60 / 24))
echo $(($(date +%s) / 60 / 60 / 24))
echo `date +%s`/86400 | bc
Depending on the language you're using it's going to be something simple like
CInt(CDate("1970-1-1") - CDate(Today()))
Ironically enough, yesterday was day 40,000 if you use 1/1/1900 as "day zero" like many computer systems use.

Resources