Questions tagged [date]

the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.

Filter by
Sorted by
Tagged with
0
votes
1answer
26 views

How do I specify a date range in a wget script for multiple files to only download what I need?

I am trying to download a lot of data for some research from the CMIP6 website that provides wget scripts for each model. The scripts are for every 6 hours or month from 1850 to 2014. The date ...
0
votes
2answers
48 views

Date output in expected format between two dates

I want date output in format like... 01/01/2020 02/01/2020 03/01/2020 04/01/2020 05/01/2020 06/01/2020 07/01/2020 08/01/2020 09/01/2020 10/01/2020 11/01/2020 12/01/2020 13/01/2020 14/01/2020 15/01/...
0
votes
0answers
15 views

What controls date format in OpenOffice writer?

I'm filling out a form which someone else created in OpenOffice. There is (apparently) a date field which is annoying. OpenOffice changes what I've typed into a date format NN/NN/NN. I'd rather ...
0
votes
1answer
32 views

How to set the timezone of a Linux host to BRT (Brasilia Time)?

I've a scenario that needs the timezone on the host to be BRT which is currently PST. I'm expecting the result of date to appear like Wed Jan 30 19:30:36 BRT 2020 I've checked the /etc/localtime ...
0
votes
2answers
42 views

Compare date and timestamps

I am trying to compare two timestamps and if x is greater than y then do some action. I tried it with bash on my Linux machine but I get an error "invalid date" here is my code: #!/bin/bash x='2020....
0
votes
2answers
35 views

Convert mm-dd-YY to Timestamp at Midnight UTC

I need to convert a mm-dd-YY string to a UNIX timestamp for use with HubSpot's API. Said API requires that dates be set to midnight UTC. I can convert the date using: date -j -f "%m-%d-%Y" "01-20-...
0
votes
1answer
81 views

Compare timestamps

I am trying to compare timestamp of the latest modified file towards current time and if the diff is more than two hours I am trying to print that out. How can this be done? The following command ...
0
votes
2answers
54 views

How can this shell script (no bash) display seconds as DDD:HH:MM:SS?

#!/bin/sh INTERVAL=12 TOTAL=3388888 DURSECS=$(($TOTAL * $INTERVAL)) printf "\n$DURSECS seconds.\n" printf "\nFormatted as DAYS:HOURS:MINUTES:SECONDS - DDD:HH:MM:SS - the total duration will be:\n" # ...
0
votes
2answers
57 views

how to add time from string with %Y%m%d%H%M%S format

look at my shell script #!/bin/sh aaa=20200101101010 bbb=$(date -d "$aaa -5 minutes" +'%Y%m%d%H%M%S') echo $bbb i want to get: 20200101100510 but result is: 20200101101009235500 what happend? ...
0
votes
3answers
68 views

How to add time to a date variable in linux?

tried this but failed now=$(date +%Y%m%d%H%M%S) past=$(date +%Y%m%d%H%M%S -d "${now} -5minutes") echo $past result: date: invalid date ‘20200120175610 -5minutes’ TT
0
votes
3answers
38 views

Invalid date on one system; perfectly valid on another system?

My code takes a start hour, and then defines a few other date/time variables from that start hour. Like so: shour=$(date -d "yesterday 3PM" -u) dd=$(date "+%d" -d "$shour" -u) sdate=$(date "+%Y%m%...
0
votes
2answers
41 views

How to convert date string to milliseconds in mac os shell?

I have the following date string 2020-01-17T06:41:48.000Z. I would like to convert it to such as 15810232300 which is milliseconds type in mac os shell. How to achieve it?
2
votes
2answers
37 views

Get last X minutes of log file that has particular timestamping

I am trying to go through an IPA host's log file to grab the last five minutes of content and get updates on things like new user creations or DNS changes. I want to cron this so every five minutes it ...
2
votes
2answers
71 views

Getting file modification time in POSIX shell

Is it possible to get file modification time from shell using only POSIX features? Ideally in unix timestamp (seconds). Everything I was able to find was using stat(1) but that does not seem to be ...
2
votes
2answers
64 views

increment a variable date by a month

Is there way on how to increment an input date by one month without using the date -d option? My machine do not have that functionality. Sample: $yearmonth=201912 Expected Output: 201912 202001
2
votes
0answers
45 views

2038 problem behaving differently in different time zone

I am working on 32 bit linux and i understand 2038 problem https://en.wikipedia.org/wiki/Year_2038_problem Anyhow , when i try to use date command to set time beyond 03:14:07 UTC on 19 January 2038 ...
3
votes
2answers
42 views

How to move files in subdirectories older than x days?

Basically I want to do this: mv /path/sourcefolder/* /path/destinationfolder/ but only with files older than eg 90 days. MV has to copy the subdirectory structure of the source-path if necessary. ...
1
vote
0answers
61 views

How to change date format in Thunderbird

The date format in the date column (inbox folder) is as follow: dd-mm-yy hh:mm. The problem is that when displaying emails from days or months represented by a single digit it messes up the alignment ...
0
votes
0answers
34 views

Timer to know when script ended with total time [duplicate]

I wrote some bash script, which should run approximately around 1-2 hours. I want to add timer that will capture the time that script is running, is it possible ? ./script.bash . . . . TOTAL TIME =...
1
vote
1answer
79 views

How to check if 'date time' timestamp between two 'date time' timestamps

I have searched and found several ways to check if a timestamp is between two timestamps but all methods assume HH:MM:SS format only, not taking into account date. My real life scenario is timestamps ...
1
vote
2answers
63 views

Understanding find with atime, ctime, and mtime

So, I understand the difference between the three ideas in the title. atime -- access time = last time file opened mtime -- modified time = last time file contents was modified ctime -- changed time =...
-1
votes
1answer
62 views

How to find all lines in the csv files from the given directory that contains date which is Saturday or Sunday?

I have a directory that contains some csv files. I would like to find files and line numbers that contains a date that is either Saturday on Sunday. Dates are of the format dd.mm.2019. Is the ...
0
votes
1answer
79 views

Use dynamic date in systemd unit

I try use date output as part of log file name in systemd unit. Here example: [Unit] Description=TCS minetest server unit [Service] Type=simple ExecStart=/home/tcs/minetest/bin/minetestserver --...
0
votes
1answer
58 views

How to do pattern matching with date in unix

I would like to extract last 1 hour data from a file. I have written the below script: Date="$(date -d -1hour +"%b %d, %Y %l:mi:ss %p")" grep "$Date" /tmp/user/file.log > TMP.log The problem is,...
2
votes
4answers
96 views

grep particular log entry greater than specific time

I am trying to filter a log greater than a specific time on a current date with specific text. I have successfully filtered text with current date in a log. Here is the command: grep "$(date +"%d/%b/...
1
vote
2answers
54 views

Checking if tomorrow is the first day of the month is failing in bash script

I have a script that runs every day. Depending on what day of the week it is, or if tomorrow is the last day of the month, it will move files into different locations. I have omitted the actual ...
2
votes
3answers
47 views

Add weeks to a date column to create a new date column

I have a file with 100s of dates (dd/mm/yyyy) like so: 10112017 23012012 01022008 And in bash I need to add 8 weeks to these dates to get output like so: 10112017 05012018 23012012 19032012 ...
1
vote
2answers
106 views

How to get difference between 2 dates in Linux?

I know this is a common question, but I do not understand how the solutions provided work. Everyone advises to change the date to seconds from the epoch and then divide by (24 * 3600) to get the ...
-6
votes
2answers
43 views

Calculate the difference between two dates in seconds using the date program?

How would I calculate the difference between two dates, for example, "January 1, 1970, 00:00:00 UTC" and "November 23, 2019, at 00:00:00 PST" in seconds using the date program?
-2
votes
2answers
76 views

script to mount a file system [closed]

Can anyone please provide me a shell script which automatically mounts a file system (/mnt/resource)? On every Monday morning, the script should first check whether the file system is mounted or not. ...
0
votes
3answers
65 views

Script to find the date of all the sundays in a year

I wanted to print the dates of the 54 sundays in a year. i have written the below script , but in the output im getting an error Script: req_date=`date +%m%d%Y` for i in {1..54} do NEXT_DATE=$(...
-1
votes
1answer
64 views

How to grep in a file using upper and lower values from another file in unix

I would like to ask how to grep in a certain file that contains filenames, criteria for grep will come from another file. Example: fileA.txt contains: newFile0001_1573001341083_123_0.txt ...
0
votes
4answers
55 views

Looking for a way to append Day of Week to end of line

In Ubuntu 16.04, I'm trying to find a way to append the Day of the Week to the end of each line in a text file given the date in field 4. Sample data: Server ID,Make,"Server Room",Datestamp,...
3
votes
1answer
269 views

Cron entry for last Saturday

I want to schedule my script for last Saturday of every month. I have come up with the below: 45 23 22-28 * * test $(date +\%u) -eq 6 && echo "4th Saturday" && sh /folder/script.sh ...
1
vote
0answers
27 views

Secure way to update Date & Time of a Linux Embedded Device

I have a Linux (4.9.171) machine running on ARM Cortex-A processor. The system has internet connection and talks to my server over SSL. At the first boot, I can configure the date and time to it. ...
-1
votes
1answer
404 views

date command on Mac bash

I have a small script in Ubuntu I want to use on a Mac. The date function isn't the same so it fails on syntax Here's the original Ubuntu BASH script; function pass () { pass="$(ldapsearch -Y ...
0
votes
3answers
84 views

Add day of the year as a number between 1-365/366 to file

Consider the below extract of a file: 19610101 060000 0.4 G 19610101 120000 2.3 G 19610101 180000 ... . 19610102 150000 19610102 180000 19610103 060000 ........ ...... 20150901 ...
2
votes
3answers
252 views

Change date format with sed or awk in file

I have file which has following format ---------------------------------------- Name: cust foo mail: cust.foo@example.com Account Lock: FALSE Last Password Change: 20170721085748Z -----------...
0
votes
1answer
27 views

ksh: appending date-time in history

Does anyone have a solution to append date and time to this as another column? It seems like it would be very useful with sorting, etc... $ history 3 history Thank you!
-1
votes
1answer
17 views

Need to get a single record based on latest date in the 3rd colum

I want to get a single record for each value in the first column there three records below have value of 2019-10-20 as the latest date, in this case first we get the three rows, then latest date of ...
2
votes
2answers
76 views

How do I convert a datetime into a epoch?

I have seen that in order to convert an epoch into a datetime the following can be done: date -d @1346338800 +'%Y%m%d%H%M%S' How can I do the opposite in Linux? I.E. convert 20191027163020 into an ...
2
votes
1answer
419 views

Timezone correct, UTC correct, time still wrong

I have an AWS EC2 server running Amazon Linux (like rhel fedora) which does not know how to tell time, or is somehow not accounting for Daylight Savings Time. This makes all of my timestamps off by 1 ...
4
votes
2answers
185 views

How do I convert the number of seconds passed since 1 January 2001 00:00 to human readable date in bash?

For example in swift you would do: let date = Date(timeIntervalSinceReferenceDate: 500000) print(date) to get: 2001-01-06 18:53:20 +0000
16
votes
7answers
3k views

Convert Unix timestamp to human-readable time

I would like to view a text file with awk/grep which contains a Unix timestamp in the first column. How can I convert it to a human-readable time while viewing?
1
vote
2answers
47 views

Working with dates in bash, does this run when I expect?

I have a bash script that runs every Monday and Thursday from a crontab entry. Inside that I have a condition to run one or another code depending on the code below: if [ "$(LC_TIME=C date +%a)" == "...
1
vote
1answer
35 views

Show who with current date as first line without script

I like to get an output on the screen of the who command, buth with the current date on the first line (without the use of a script) Following does the job, buth I prefer one command. $ who > who ...
12
votes
5answers
2k views

How could a sequence of random dates be generated, given year interval?

What is needed here is a command that generates six dates given a range of years (1987 to 2017). For example: 12/10/1987 30/04/1998 22/02/2014 17/08/2017 19/07/2011 14/05/2004 How it could be done, ...
1
vote
2answers
101 views

How to work with date command in a bash script through variable

I have a file with specific dates and i want to convert them to UTC format. so I prepared a small script I get below errors: date: option requires an argument -- 'd' Try `date --help' for more ...
0
votes
1answer
291 views

Cron: Run every day except first day of the month and first day of each week

I'm fairly new to cron and I'm trying to figure out a way to run a job every day of the week, except for the first day of each month and the first day of each week. This may sound a little odd, but ...
0
votes
1answer
24 views

A clean way to set a daily running time for a program

Kind of a noob question but I'm looking to have my networking daemon (wicd), run every day on my machine, only from 5am-6am and 6pm-7pm, regardless of when my machine was turned on, in other words, if ...

1 2 3 4 5 19