Questions tagged [date]
the "date" tag is used to classify questions about date/calendar/time manipulation, visualisation, conversion... on Unix-like systems.
1,161
questions
1
vote
1
answer
4k
views
view IPs from apache access.log for date period
I have seen someone use this command -- and it works where it pulls back all the IPS in a list/group:
cat access.* | awk '{ print $1 }' | sort | uniq -c | sort -n
However, I want to choose the past ...
8
votes
10
answers
10k
views
Convert a date from DD-MM-YYYY to YYYY-MM-DD format in bash LINUX
Scenario:
I am fetching a date value from a file into a variable and it is in DD-MM-YYYY format by default. I have to substract this date from system date. Subtraction is giving incorrect result if I ...
0
votes
3
answers
53
views
In Linux how to find if a file was read and at what time
Is there a tool or command where we can see if a file was read and at what time? I would only find for last modified.
0
votes
1
answer
89
views
Need Help with Date expression - AWK in a csv file
Situation: csv file has date column with different date formats, I want to convert them into a unambiguous date format (like +"%m-%d-%Y").
Example File data : File name = Date_Test_new.csv
3/...
66
votes
1
answer
100k
views
How do you time how long a command took to run? [duplicate]
How would you find out how long a running process took to complete?
Example:
date; dd bs=1m if=/foo of=bar; date
^This example only has 1 second of resolution.
Any shell is acceptable.
1
vote
1
answer
2k
views
What is %z useful for in GNU date?
I'm in the UK running these 2 commands (using gdate as I'm on a Mac with date (GNU coreutils) 8.32 installed):
# A UK winter date, timezone in UK at this time is GMT = UTC
$ gdate '--date=TZ="...
6
votes
2
answers
1k
views
How can I set a time zone on a Linux machine that has only very minimal cmds available?
I have a Linux machine that only has very minimal cmds available on it, for example the /bin looks like this:
/bin# ls
ash chattr clockdiff dd dumpkmap ...
0
votes
4
answers
549
views
date: starting with year and week number, how to have the date Monday
How can I get the ISO date for a specific week's Monday? For example, the Monday of the 32nd week of 2021?
I know that if I run date -dmonday +%Y%m%d I will get the the Monday date of the current week....
0
votes
2
answers
2k
views
Log search within date range
My log file looks like the following sample:
10.434.22.334 - unauthenticated 10/Aug/2020:23:45:45 +0800 "GET /eai/random.jsp HTTP/1.1" 200 74
10.434.22.334 - unauthenticated 10/Aug/2020:23:...
7
votes
1
answer
4k
views
Leap seconds and date
I've just discovered that Unix time does not include the leap seconds. I think it's quite surprising because doing that, it is slowly diverging from UTC... but that's not the point of my question.
...
16
votes
4
answers
3k
views
date - Can't Go Back More Than 115 Years or Can't Go 5879565 Years Into the Future
TZ=CEST, date (GNU coreutils) 8.32:
date -d "115 years ago"
Di 11. Aug 13:37:54 CET 1908
date -d "116 years ago"
date: invalid date ‘116 years ago’
Questions
Is it possible to ...
3
votes
1
answer
1k
views
Fiddling with locale so that weeks start on Monday
I use the C.UTF-8 locale and all is well, I'm pretty happy with it but weeks starting on Sunday...
Is there a single or combination locale setting that changes only the first day of the week, leaving ...
17
votes
5
answers
22k
views
How do I find seconds since midnight?
Using the date program, how can I calculate the number of seconds since midnight?
1
vote
2
answers
407
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 ...
285
votes
12
answers
430k
views
How do I convert an epoch timestamp to a human readable format on the cli?
How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).
0
votes
1
answer
4k
views
shell script to monitor current errors in logfile
This script monitors logfile for pattern "ora",pull error details and send email.In this case i want to pull only the last error which come in logfile.
I set crontab for every 5 minutes,so grep pull ...
3
votes
1
answer
76
views
Is there a tool to test if a date-time is in a given range?
I need to develop a script to test if "now" (e.g. the output of date) is in a given range. For now, this range is expected to be a list of days of month (e.g. 10,11,12,13,21,22,23). And I ...
0
votes
2
answers
276
views
changing datetime format Ubuntu 22 [duplicate]
Looking for a solution for changing my machine datetime format to be DD/MM/YEAR hh:mm:ss.
Currently ,Linux default is MM/DD/YEAR hh:mm:ss
This is a GCP machine , running ubuntu 22.04.2 LTS .
Thanks !
1
vote
5
answers
85
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,...
0
votes
1
answer
2k
views
busybox format date
I got a command which works perfectly on linux
date -d @$(git log -1 --format=%at) '+%Y-%m-%d_%H-%M-%S'
and now i'm trying to do same formatting with busybox, but i always fail
2
votes
4
answers
581
views
Changing non-standard date timestamp format in CSV using awk/sed
I have a csv with a few hundred thousand lines and I'm trying to change the date format in the second field. I should also add the second field is sometimes not populated at all.
The deplorable input ...
3
votes
0
answers
54
views
How can I format the date and time in accordance with ISO 8601 / RFC 3339 using systemd?
How can I configure the environment of a systemd based Linux system to display the date system-wide in the format yyyy-mm-dd?
This date format adheres to the specifications defined ISO 8601 and RFC ...
186
votes
7
answers
299k
views
How can I have `date` output the time from a different time zone?
I have a server running with the time zone set to UTC. It seemed like that was generally a good practice (please correct me if I'm wrong).
Anyhow, one of the servers I connect to, in order to scp ...
2
votes
2
answers
184
views
Update any date to the current date in a text file
I have a text file which contains several occurrences of dates. All the dates are written in the format Mon-DD-YYYY. I have to update all these dates in the current date keeping the format Mon-DD-YYYY....
7
votes
2
answers
462
views
How to automatically set the modification (or creation) time of a Quicktime video file based on its meta data?
In a shell, how to automatically set the modification (or creation) date and time of a Quicktime video file based on the metadata in the file with a single command (or a single command line)? For JPG ...
0
votes
1
answer
44
views
Write a script to obtain the date of the last month [closed]
I would like to obtain the date of the previous month as output and store it in a variable using a bash script.
For example, if today's date is 07/04/2023, I would like the output to be 06/04/2023.
2
votes
1
answer
2k
views
In crontab, can I specify a number of days before the end of month?
I want to run a script that generates a weekly report every Saturday night at 11 PM, and another script that generates a monthly report on the 1st of each month.
I don't want the weekly report to run ...
3
votes
3
answers
293
views
MAC OSX / Bash Problem - Sorting strings as a date
I have file output in a CSV file I want to sort by date time but the date time appears as below, with the time and year appearing in a different order.
Using this command to produce the file listing:
...
1
vote
1
answer
1k
views
How to schedule cron jobs in linux?
I have script files.
.file I need to run only on the first day of the every month.
How can I do this with my cron job?
52 07 * * * bash '/home/linux/tanu/cat.sh'
5
votes
1
answer
1k
views
ls: bash: printf: `Y': invalid format character in VS Code, not in Terminal
I upgraded to Linux Mint 21 (based on Ubuntu 22), having number of small issues, one of which is in VS Code, not in Terminal (gnome-terminal), running ls alias:
bash: printf: `Y': invalid format ...
3
votes
2
answers
2k
views
Make date change permanent in EC2
How can I manually set date and time to future in EC2 instance and make it permanent, so it won't reset after reboot ?
I can change date using this command:
$ sudo timedatectl set-time "2017-12-09 ...
3
votes
2
answers
2k
views
PERMANENTLY change the output format of the 'date' command in my Kali Linux
So I have 2 different Linux installations. One of them is Ubuntu and the second one is Kali.
When I run date command with no options/arguments on my Ubuntu install I get:
michal@ubuntu:~$ date
Thu 24 ...
137
votes
18
answers
302k
views
Quickly calculate date differences
I often want to make some quick date calculations, such as:
What is the difference between these two dates?
What is the date n weeks after this other date?
I usually open a calendar and count the ...
3
votes
2
answers
4k
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 --...
2
votes
3
answers
2k
views
How does one sort dates in a text file?
It's 14.08.2019, there is a text file that contains a list of dates (dd.mm.yyyy):
30.07.2018
14.08.2019
18.08.2019
20.08.2019
01.01.2020
The dates in the list are deadlines.
What the output should ...
1
vote
3
answers
934
views
Viewing images date-wise in an image viewer
I am on Debian testing. I have come across this problem before and haven't found any resolution so far using search-engines, perhaps not precise enough, dunno.
The thing is I have a folder/directory ...
3
votes
1
answer
3k
views
I'm trying to compile alsa-driver-RTv5.18 but get date-time error for gcc 4.9.2
/home/user/Downloads/Rt-Linux-HDaudio-5.18/alsa-driver-RTv5.18/alsa/acore/info.c:1065:22: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
"Compiled on " __DATE__ " for ...
1
vote
2
answers
706
views
How to move (image) files to other directories based on files' dates
I have a directory (currdir) with 24000 images on a CentOS/cPanel server.
I want to split this directory by moving images from this directory into other directories (or sub-directories inside currdir) ...
7
votes
2
answers
4k
views
rsync time comparison - what's the precision of the Modified times comparison
I'm doing some synching with rsync using:
rsync --rLvv --times --size-only
For my initial sync. My idea, now is to use:
rsync --rLvv --times
To synch files that have a new modified time. My ...
1
vote
0
answers
77
views
Linux UTM VM Hardware Clock is Incorrect
My machine natively runs MacOS Ventura 13.3.1. I am using UTM to run 5.14.8-arch1-1. I am on PST. The output of sudo hwclock --verbose is as follows:
hwclock from util-linux 2.37.2
...
Hardware clock ...
1
vote
3
answers
6k
views
Number of Seconds since epoch in solaris 10
I am trying to get the number of seconds since the epoch in both Solaris 10 and Solaris 11.
On Solaris 11, "date +%s" is giving me the output (from bash), but the same is failing on Solaris 10.
What ...
12
votes
1
answer
19k
views
at command: Garbled time
I am not able to run at command.
edward@ArchLinux:~$ at
Garbled time
what is wrong? Am I running it wrong?
0
votes
1
answer
105
views
Rsync with date filter over ssh
I use the following command successfully
rsync -e 'ssh' -avr [email protected]:/home/mikrotik /bck/mikrotik/
How can I add date filter to this command? I would like to sync only files that are newer ...
0
votes
3
answers
422
views
Compare multiple date & time in shell script
I have below output with jq command , where I want to compare all the date & time and tell which is the latest one
Mon Feb 20 09:22:25 2023
Mon Feb 20 17:42:13 2023
Thu Mar 2 05:55:07 2023
Tue ...
0
votes
1
answer
19
views
Getting year of Postixct format
"Thu Apr 21 11:15:00.375 2022" how to get the year of this expression?
Followings are tested.
1- as.POSIXct(strptime("Thu Apr 21 11:15:00.375 2022", format='%c'),origin='1970-01-01'...
0
votes
1
answer
385
views
Chrony - Synchronize the date and time of all host computers in a network without internet connection
I have two machines,
host A with IP 192.168.0.1
host B with IP 192.168.0.2
They connected to the same network and I would like to set the date and time of machine B to match those of machine A. ...
72
votes
9
answers
179k
views
How do I set time and date from the Internet?
How do I retrieve the date from the Internet and set my computer's clock, from the command line?
80
votes
9
answers
320k
views
How to append date to backup filename
I need to make a backup of a file, and I would like to have a timestamp as part of the name to make it easier to differentiate.
How would you inject the current date into a copy command?
[root@...
0
votes
1
answer
38
views
Set explicit time with date
When I tried to set time with
$(date +%s -d "2022-04-10 12:12:12")
I get the time
2022-04-10 19:12:12
How can I set the time explicit?
0
votes
0
answers
19
views
date -d 'last month' yielding incorrect results? [duplicate]
I noticed an awkward (at least to me) behaviour of the date command:
jasio@zuza:~> date -d 'this month'
śro, 29 mar 2023, 15:51:42 CEST (1)
jasio@zuza:~> date -d 'last month' (2)
śro, 1 mar ...