The shell command touch -t 2203231037 file stores the year in the HH:MM file attribute resulting in 2022 instead of 10:37. This is a curriculum exercise, with the remark that this side effect won't be consider as wrong for the purpose of the exercise.
However, what is the correct usage of the touch command to get the right time posted for hours and minutes?
Related
When we are running a Meltano build/test cycle (such as in a CI/CD pipeline), we want our Singer pipelines to run as follows:
Don't use pre-captured state bookmarks that might permit a stream to entirely not have a meaningful run. (For instance, if there are zero records new, or not enough records new to trigger a representative test.)
Don't require developers to constantly have to push forward a hardcoded start_date. (What starts out as a "fast" test of a month of data eventually becomes a much longer-running test covering multiple months.)
For any tap name tap-mysource, we should be able to set $TAP_MYSOURCE_START_DATE to provide a default start_date config value. What's a good way to provide a default relative start time for CI builds - for instance, a rolling 21 day window?
I think most use cases probably running on GitHub Actions but we also use GitLab CI.
As of now, there isn't an expression language to perform today()-n and provide relative start dates in that manner. However, you can initialize an environment variable with the relative date prior to execution, and Meltano can pass that a dynamic input to the tap by way of the naming convention <PLUGIN_NAME>_<SETTING_NAME>.
Depending on your flavor of OS, this may need to be slightly adjusted:
On Mac:
N_DAYS=1
TAP_MYSOURCE_START_DATE=$(date -v-1d "+%Y-%m-%d")
echo "Using dynamic start date of today-$N_DAYS: $TAP_MYSOURCE_START_DATE"
meltano elt tap-mysource target-mydest
On Ubuntu:
N_DAYS=1
TAP_MYSOURCE_START_DATE=$(date +%Y-%m-%d -d "$N_DAYS day ago")
echo "Using dynamic start date of today-$N_DAYS: $TAP_MYSOURCE_START_DATE"
meltano elt tap-mysource target-mydest
Ref:
`date` command on OS X doesn't have ISO 8601 `-I` option?
https://stackoverflow.com/a/1706909/4298208
Background: I'm on a team that deploys software to servers in over 30 different timezones. Each server location has it's own maintenance window. Our SysAd team is in 5 different locations. Currently we use an internal wiki page with a table of server locations and google time conversion links like this. So our internal wiki page of maintenance windows is full of timezones of the servers, if they follow DST offset or not and then a conversion link for the start time and another google conversion link for the end time of the maintenance window. It's time consuming keeping track of which servers can be patched right now. As some servers are in the same timezone as other server but maybe doesn't follow DST or not it's a mess of keeping track. Some of the Software Devs at work keep a full bookmark folder of all of the conversion links and I wanted to send them a script that can simplify this.
Goal: I basically want a script to be able to compare the SysAds current timezone to the timezone of the different servers. In the end I want an echo statement of which server can be patched right now, and eventually I want to add further logic later that will asses the time until next maintenance window and that servers location.
Problem #1: I'm new to scripting.
Problem #2: When doing what I thought was a simple TZ comparison it's not outputting what I expect. I feel once I understand why the output below is as such I think I can figure out the rest of the logic. I don't necessarily care about specific hours and minutes at this point. Just why is the If statement not outputting "the same".
Desired script:
#!/bin/bash
##SysAd Sets his own timezone in the first TZ variable.
export TZ=America/Los_Angeles
TZ1=`date +%::z`
echo $TZ1
##Timezone of Server in location 1
TZ=America/Los_Angeles
TZ2=`date +%::z`
echo $TZ2
if [[ " TZ1 " == " TZ2 " ]]; then
echo "the same"
else
echo "not the same"
output:
% ./test.sh
-08:00:00
-08:00:00
not the same
expected output is that they are the same. echo'ing out both the TZ1 and TZ2 variable are both "-08:00:00"
It should be:
if [[ "$TZ1" == "$TZ2" ]]
A bit of code shows {"time":1578475688. This doesn't match the time that it was at the time. The time was around 5:27 pm at this time, and I am wondering what this means.
What you got was a UNIX Timestamp. A UNIX Timestamp shows you the time that has passed since Jan 01 1970. (UTC)
You can't really see the time how we normally read it in the number you get but you can look it up through websites like these: https://www.unixtimestamp.com/index.php
Hopefully this can help you understand what the number you got is.
I have a program in Linux to write log into files on a regular interval (for
example: 10 minutes every file), so I have a directory hierachy like this:
In which, 20151001 stands for the log dir for the day
2015(year)/10(month)/01(day), and 00 stands for the first hour in the day,
and 00.00 stands for the log file for the first 10 minutes in the first hour
of the day.
In my shell script I need to detect if there is any previous log file is empty,
for example if now the time is 2015/10/09 09:32, the newest log file should be
20151009/09/09.03, the file 09.03 could be an empty file, but the other
older files should not be empty. In order to simplify the problem, I just detect
if the previous file is empty, so I just detect if the file 20151009/09/09.02
is empty. However I have to handle some edge cases, like:
If now the time is:
2015/10/09 09:01
the previous file is in another directory, it’s:
20151009/08/08.05
If now the time is:
2015/10/09 00:01
the previous file is:
20151008/23/23.05
Is there any powerful algorithm or tools to handle my problem, especially the
edge cases?
i want to make a Visual basic script console app that prints edited if a file has been modified. for example if i have a text file with some notes in and i add it to a folder when its edited the program checks the folder its in and the files then prints the name of the file and modified or not modified
how would i go about doing this i am relatively new to Visual basic script i probably have 4 months basic experience.
console.writeline("what do i do?")
console.writeline("and how do i do it")
and I'm trying to do it as a console app so the preferred outcome i would like to see would be
File Checker
test.txt - Edited
test2.pptx - Un-edited
etc etc etc
If you need an immediate notification, WMI is probably the best route. But WMI will also require your process to be running (in a blocked state) all of the time. Alternatively, you could schedule a VBScript to be launched at some interval and it could check each file's last-modified date against a text file or database that you use to store the modification date the last time the script was run.
An even easier solution would be to just check if the modification time changed since the last run. For example, if your script runs every 10 minutes and you discover a file that was changed within the last 10 minutes, report it.
With CreateObject("Scripting.FileSystemObject")
For Each File In .GetFolder("c:\folder").Files
If DateDiff("n", File.DateLastModified, Now) < 10 Then
' File has been modified in past 10 minutes.
End If
Next
End With