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
2answers
1k views

spaces between date format

what's the best way in shell to create custom date format and adding any space between the format? For example the below command for print yesterday date by the format Oct 9 custom_format="$(date ...
0
votes
1answer
128 views

Copying latest files (date=today) from local to HDFS with spaces in the names on daily basis

I have daily incoming files in a local folder(/home/gas_uk). I want to put/copy the latest files from local for today to the HDFS directory (/apps/hive/warehouse/gas_uk/). I have tried : find /home/...
0
votes
1answer
402 views

Using sed to give current date in mm/dd/YYYY format?

So I know that in order to replace something with the current date it would be sed "s/something/`date +"%m-%d-%Y"`/" file.txt This would give me the date in mm-dd-YYYY But I want to be able the get ...
2
votes
1answer
958 views

Why does `date` ignore TZ environment variable?

On Ubuntu 18.04, I have the following behavior of date: $ date --version | head -n1 date (GNU coreutils) 8.28 $ date Вт окт 8 13:18:18 MSK 2019 $ TZ=UTC date Вт окт 8 10:18:23 UTC 2019 So far so ...
-4
votes
2answers
6k views

What is the format in date command to display the current date as "DATE: 27/11/17

I need a prefix DATE:. how can I display prefix along with the date. date +%d/%m/%y This displays only the date. I need a prefix string also. Output should be DATE: 27/11/17
-1
votes
1answer
939 views

Finding files based on the date contained in their filenames

In the script below, I ask a user to input a date range and apply that range to filter the result of a find command. The command applies to log files whose names contain a date, as in filename-...
1
vote
1answer
274 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 ...
-1
votes
1answer
40 views

How can I print n days old date?

For 2 days old date I usually do this echo $(date -v -2d) What i am looking to do is something like this n=5 echo $(date -v -nd)
0
votes
0answers
247 views

Linux system with no internet connection, dealing with system date

We're developing a vending machine that will run a Xubuntu 18.04 in a Single Board Computer with a browser in kiosk mode, the machine won't be able to connect to the internet on most of the cases. ...
1
vote
2answers
544 views

Create directory with timestamp of newest files

I am trying to create a directory based on the timestamp of the 2 newest files in a directory and then copy those 2 files in to the newly created directory. SO for example -rw-r--r-- 1 root root 0 ...
0
votes
0answers
50 views

is there a limit in -ctime for a find?

I am trying to find all folders older than 5 years old to remove them. find . -type d -ctime +1800 -print Just as a test yields no returns, it seems like there is a limit on what can be passed to ...
0
votes
1answer
46 views

PHP ip request -- repeat every 5 seconds with the date in the output

I have a code in php and it shows ip adress. But it works only for once when I enter. So I want to use this code to works in every 5 second. your ip : 5.4.3.2.1 ; 18:05 your ip : 5.4.3.2.1 ; 18:10 ...
0
votes
1answer
66 views

Need an "at" Command Timestamp That Runs Command Monthly at Given Day

Need an at command timestamp that run some command at given day monthly, like for example, every day 15, as would follow: $ at every 15 day So that on every day 15, it would run some command. How ...
3
votes
3answers
890 views

Increment a variable timely in bash script

I want to increment a variable by one every 3 seconds. Is there any way to do that using bash? I had a program running in infinite loop in which I am doing some stuff with a variable; I want to ...
0
votes
1answer
42 views

How to interpret /var/log output

I have trouble interpreting the following output from /var/log. Both lines show the same result but of different date? What does this mean? Currently doing an audit to ensure that the directories are ...
0
votes
1answer
72 views

Linux command-line to find duplicate files and only retain most recent

I have a directory which contains a huge number of XML files. They are labelled as filename_date_time_checksum.xml, which means I've got thousands of files which are identical but separated by ...
0
votes
1answer
973 views

Convert string to date in AIX and get difference between date time

I have a log file like this: 2019.09.02 06:40:28 --- 2019.09.02 06:43:34 --- 2019.09.02 06:43:41 --- I need to read the file and get the difference between datetime "2019.09.02 06:43:34" -and- "...
5
votes
2answers
512 views

dmesg: custom time format

dmesg has the option -T to print human-readable timestamps, and new versions have the option --time-format, where the time format can be changed, for instance: --time-format iso Unfortunately, the ...
1
vote
0answers
42 views

How to determine if file has been modified in the last x seconds

I want to determine if a file has been modified in the last x seconds on MacOS or Debian etc. is_file_older_than() { seconds="$1" file="$2" echo "The file $file" modified_secs="$(date -r "$...
0
votes
2answers
119 views

Bash Time Difference

I have a log file and I need to make some calculations between two jobs to find time difference. In my log file I am supposed to calculate time between the jobs incoming request and candidate list ...
6
votes
1answer
9k views

How do I change the output of `date` back to 24-hour format?

Apparently a recent change (in Glibc 2.29?) causes the date command to start printing times in 12-hour format: $ date Fri 23 Aug 2019 07:34:13 PM PDT This is for my default locale $ cat /etc/locale....
2
votes
1answer
182 views

Using subset in sed for replace with regex

Consider some data that looks like this: "2019-12-12 00:00:01","2012-01-01 01:01:01" I wish to replace it so that they are valid datetime json values: "2019-12-12T00:00:01+01","2012-01-01T01:01:01+...
0
votes
1answer
927 views

How to get list of processes from N days ago from ps output

How to get list of dates from an output of ps command to only show those processes beyond 30 days? My goal is to kill these processes. I can easily do this by killall command. E.g. killall -u user --...
0
votes
1answer
128 views

How to restore timezone from RHEL 5.x to RHEL 7.x?

We have scripts to reinstall RHEL 5.x to RHEL 7.x and install our application, but I need to update timezone according to old one. So how to restore timezone from RHEL 5.x to RHEL 7.x using /etc/...
0
votes
2answers
888 views

Convert Date string in timestamp

I can't find the right syntax to convert a string date in epoch timestamp. The script is: date -d '2012-03-02 22:00 EDT' +%s DATEJ=`echo -n \'2012-03-02 22:00\'` echo $DATEJ date -d $DATEJ EDT +%s ...
3
votes
2answers
495 views

How to convert 2019-08-15 date format to August 15, 2019 in the command line?

Given a bash variable with the value 2019-08-15, is there some utility that can convert that date to the format August 15, 2019?
0
votes
2answers
673 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
2answers
347 views

How to sort a list of dates in a text file [duplicate]

Let's assume I have a text file with a list of dates (dd.mm.yyyy). 01.01.2020 01.03.2020 01.01.2019 How do I sort them out? (oldest to newest in a "from top to bottom" fashion)?
1
vote
0answers
60 views

Change timezone of mov files

I forgot to set the correct timezone in my camera during a vacation and now the times are all off by 7 hours. To correct this for the image files I used exiv2 -a -07 adjust *.JPG which changes the ...
0
votes
1answer
143 views

How to configure remote machine to use local timezone on login?

I work on a remote Linux machine which is located in a timezone which is off by 9h from my local time. I spend most of my time working from the shell, dealing with files versions and logs. Because the ...
2
votes
2answers
1k views

Why cannot I set the date of my GNU/Linux machines to the Epoch?

Both on a Raspberry Pi and on a Ubuntu 16.04 x86_64 machine I have access to, running # date -s @0 returns date: cannot set date: Invalid argument thu 1 jan 1970 01:00:00 CET and I wonder: what ...
1
vote
2answers
185 views

xdebug - remote log time is wrong

I noticed that the xdebug log time is always two hours too early. For example it says the log is created at 7:15 am even though it is 9:15 am. If I execute date in my terminal, then I get 9:15 am
0
votes
0answers
1k views

How to zip/tar files older than 30 days in archive directories?

I am very new to bash scripting, so bear with me, please. I need to collect, compress and delete files in the archive directory of a directory tree older than 30 days old for each respective folder. ...
3
votes
1answer
185 views

Change file modified date using date from file name

Change last modified date of multiple files as per date mentioned in the file's name Files are 04-01-1981 XXXXXYYYYZZZZ.xml 19-11-1982 XXXXXYYYYZZZZ.xml 25-12-1981 XXXXXYYYYZZZZ.xml The reason it ...
-1
votes
1answer
194 views

year should be 4 digits only , only then script should paas

I mean $yy should be 2019, 2020, 2021, etc. $yy should fail if it is 20199 201987 It should be 4 digits only. How to check this condition.. yy =$1 if [ $yy > 4 ] ----- something like this then ...
3
votes
2answers
2k views

List most recently modified files in a `ls`-style output without running `ls` on the entire directory?

I have a directory with tens of thousands of files. I want to list the most recently modified files (for example files modified within the last day or whatever). The following command works but is ...
0
votes
1answer
2k views

Linux system-time differs from RTC time

I'm running Debian Stretch and Linux kernel version 4.9.110-3+deb9u4, with a modified config. I'm observing the following weird behaviour Set the hardware clock to 2016-01-01 00:00:00 UTC Reboot ...
0
votes
4answers
249 views

Modify date of a file to be older that any other file in a certain folder

I would like to modify the date of a file file in order for it to be older than the ones present in the directory dir. The value of the time difference doesn't matter, as the goal is only to make it ...
-1
votes
2answers
75 views

How to calculate a Time Zone from my server [duplicate]

My server runs on UCT time. What is the command to check a specific time zone? i.e. America/New_York And to be clear, I don't wish to update the servers time zone, I just want to know what it ...
0
votes
1answer
454 views

bash + grep only the time stamp from output

we want to capture the time from the output and not the time from the command sshpass expected output Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 Sun Jul 14 12:47:49 UTC 2019 but from ...
2
votes
1answer
887 views

Get current date and time in standard ISO 8601 format on console in FreeBSD

I would like to get the current date-time conveniently on the console in standard ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ For example: 2019-07-13T01:09:35Z I know the date command displays the current ...
0
votes
0answers
112 views

pssh + verify date between machines and alert if date difference is more then 3 second

we are using the following great pssh command in order to see if time differences is more then 3 second between machines pssh -i -o /tmp/out/ -e /tmp/err/ -H "master01 master02 master03 worker01 ...
0
votes
1answer
144 views

Automatic expiration date for UNIX group membership

I want to add user to specific UNIX group only for 6 months. Then I want automatically kick him out of this group and I don't want to expire his username. Which command should I use?
0
votes
2answers
919 views

AWK Command to Select Date Range

I would like to monitor the /var/log/secure file for user activity. I need to be able to provide a start date and select lines only occurring after that date . I have played around with awk for a ...
0
votes
0answers
532 views

FTP listing files (ls) with dynamic date YYYMMDD pattern

Following a previous answer I'm trying to list the files on an FTP server that match a pattern, as shown below event_date=`date +%Y%m%d` ftp -n XX.XX.XX.XX <<END_SCRIPT ls *${event_date}* ...
0
votes
1answer
779 views

find . -type d -mtime +1 only shows one file in a 4 day span [duplicate]

I was trying to use find with -mtime +1 to find all directories older than 24 hours but having issues getting this done. I understand that using -mtime +n should remove n*24 hours of data but it seems ...
2
votes
1answer
74 views

Can we preserve the timestamp of parent directory after modifying the files inside it?

I have a folder structure: /home/us3r/scripts I've some scripts inside the scripts folder. Now, i want to preserve the timestamp of the scripts folder even if someone does a vim and saves any of the ...
2
votes
2answers
110 views

Add one year to the creation/modification date

I'm trying to add one year to the modification and creation dates to all files of a folder. I found many examples to modify a whole date (not only the year). How can I add one year to the creation/...
2
votes
4answers
521 views

Delete folders but keep 20 newest, 7 days old

I am looking for a way to delete folders that are older than 7 days, but always have 20 newest folders. similar named folders with _SAME_NAME_@tmp should be deleted as well. I'm stuck with making ...
0
votes
2answers
258 views

Alias for recent log files

Usually when I'm searching the logs, its for something that happened recently. I end up tabbing at bash prompt to complete the names. I finally did bash alias that uses date arithmetic to build the ...

1
3 4
5
6 7
22