Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [date]

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

0
votes
1answer
10 views

Builroot date is wrong

When I flash a buildroot image for the raspberrypi3 using the date command will give me 1970-01-01. I have to manuel reset that every time. What would be the correct way to handle this, should I ...
0
votes
0answers
15 views

Rewrite files last modified date

I have a folder of contents which I wish to archive. Each file has a different last modified date. Is there a way to change the last modified date of all the files to a specific one from the past? I ...
0
votes
1answer
46 views

Rewrite last modified date when unzipping archive

Is there a way to rewrite the last modified date of all the files inside a .zip file to the date of extraction? Basically, whenever someone unzips the archive, the last modified date of all files is ...
1
vote
2answers
78 views

script with date work on Linux but not on AIX

I wrote a script to that works fine on Linux but fails on AIX 7.2. My script uses the command date with -d. The purpose of this script is to get the last day that is not a Saturday, Sunday or a ...
0
votes
1answer
19 views

Add log filename with minus 3 day in crontab

I want to set my log file name into crontab with date - day, not current_date. I've already success for current date like this: 00 02 * * * bash run_myscript.sh > /logs_myscript_`date "+\%Y\%m\%d"...
6
votes
1answer
237 views

Escape a mm/dd/YY backup date in a file name

I have been trying to: cp file.csv file.$(date +%D).csv But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories. And I have been trying again to: cp file....
1
vote
6answers
55 views

Get list of folders that are after certain number

I have a folder which subfolder naming convention is like yyyymm for e.g. 200801, 200803 etc. I want to list down folder after 201412 via command line means to upload to S3. Is there a way to do it?
2
votes
1answer
56 views

How to read dd/mm/yyyy date string in date -d UNIX command?

I am trying to dynamically convert one column in text file containing date in dd/mm/yyyy hh:mm:ss format to yy-mm-dd hh:mm:ss. Following command is working but giving output in yy-dd-mm and NOT yy-mm-...
0
votes
0answers
13 views

Buildroot date is set to Jan 1, 1970

why does buildroot automatically set the date in the title. And how do I fix that? Or do I have to make a script to manually set that?
0
votes
5answers
86 views

Get date of Monday two weeks ago from particular date using GNU date

I understand the command date -d 'last-monday - 14 days' +%Y%m%d will print the Monday two weeks ago from "Today's date". I need a way to test this for different dates and see the result. Almost like ...
1
vote
1answer
37 views

Calculate difference in numbers and save in colon-separated time format with bash script

I have a tab-separated file, e.g., 0018803 01 1710 2050 002571 0018951 01 1934 2525 003277 0019362 02 2404 2415 002829 0019392 01 2621 2820 001924 0019542 01 ...
1
vote
0answers
15 views

Timestamp retrived with `date -r file` does not fit the time order of commands [duplicate]

I was playing around with the command date to create timestamps and profile the execution of a script. I decided to set four of them, named t1 through t4. For t2 I created an empty file whose last ...
0
votes
3answers
69 views

Zipping the 10 most recent files

Basically my requirement is to find 10 latest logs and compress it into zip. I have tried command ls -Lt | head -10 | zip log.zip *.log, but output is not matched.
1
vote
1answer
49 views

Checking for invalid date in bash script

I am checking for a valid date scrpt.bash test 2019-05-03 date -d $2 2>: 1>:; c=$? If $c is 1 then the date is invalid. If I enter 2019-05-03 I will get a 0 which is correct. If i enter 2019-...
0
votes
1answer
45 views

Creating a for loop with find -exec and while

I am trying to make this script that loops through video files created between hours 00 and 12, convert them with ffmpeg and then remove them. The script works in terms of finding the files and ...
0
votes
2answers
34 views

Manually set time overwritten without a time sync active (in a VM)

I'm trying to set a fake time on Ubuntu 18.04 (systemd 237) for purposes of testing an execution of a monthly periodic task. This is running on a virtual machine (virtualbox with guest additions). ...
0
votes
1answer
25 views

How to add both date and space to a filename [duplicate]

If I execute touch $(date '+%F %T'), I expect one file whose filename comprises the date and time to be created; but instead two files are created: one whose name is the date, and the other whose name ...
0
votes
2answers
34 views

Format date output minutes as the fraction of an hour

How do you format the date time output so that 11:30 is printed as 11.5?
1
vote
2answers
91 views

How to search for a specific string in files from a specific date?

How can I search for a specific string in files from a specific date? For example, I have 3 files named 'a1' dated: 20 Feb, 'a2' dated 21 Feb, 'a3' dated 22 Feb. Now I want to search for a certain ...
0
votes
0answers
33 views

SFTP the latest file

I need to sftp to a remote server, find the latest file on the server, download the file, and rename the file so it's not used again. I have no control over the file naming convention, so I need to ...
1
vote
2answers
102 views

Embedded Linux: setting the time without NTP

Working on a embedded Linux device built using yocto that is pulling a date via uart from another device with a satellite connection. By the time we have access to this date, we are well into a fully ...
0
votes
1answer
45 views

Daylight saving in Debian 9

I would like to know how to enable Daylight saving support for Debian 9 with LXDE. My timezone is set to Europe/Rome. However my clock is one hour ahead and - considering Daylight saving - it shouldn'...
0
votes
1answer
46 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'
1
vote
3answers
41 views

Sort date in format “date +%a %b %d %T %Y”

I want to Sort the data in a file considering the date column (last column in the sample data). I have tried some commands but didn't get succeeded. Sample data: Beendet|48149|1550804401|STR|Fri ...
1
vote
2answers
388 views

How to compare two dates in bash script?

I am trying to compare todays date with the last modified date from a file. DATE=$(date +"%F") LASTMOD=$(stat $i -c %y); LASTMOD_DATE=$(cut -d' ' -f1 <<<"$LASTMOD") if [ "$LASTMOD_DATE" -...
0
votes
1answer
40 views

conversion of date into seconds in unix

I have a requirement where I will be give the time in below format 2019-02-08T19:24:30.220Z by this I need to output number of days between the given date and present date. given date = 2019-02-...
-1
votes
1answer
48 views

How to switch to the last added folder in that particular folder in S3 bucket

I have a **S3 bucket in which starting of every month ... will be added. And in the month lder daily **new files will be added .
0
votes
1answer
144 views

date addition in bash doesn't work in docker

I have followed examples on numerous stack exchange websites and various other tutorial websites on how to do date math. I have tried linux (on containers) I get the exact same error: $ docker run -...
0
votes
2answers
68 views

Bash-Script: rename files in folder order by file-date

I want to rename files in order of file-date; from example: file_1.pdf file_2.pdf to: file_1_ONE.pdf file_2._TWO.pdf The script must rename the first file to "ONE" ordered by file-date.
15
votes
5answers
1k views

Subtract time using date and bash

All the other questions on the SE network deal with scenarios where either the date is assumed to be now (Q) or where only a date is specified (Q). What I want to do is supply a date and time, and ...
0
votes
0answers
41 views

Find the difference between 2 dates [duplicate]

Job1 07/09/2018 22:40:57 01/20/2019 11:48:52 Job2 11/28/2018 19:23:49 01/20/2019 05:29:49 Job3 10/10/2018 01:51:52 01/19/2019 23:08:13 Job4 12/08/2018 20:51:34 01/19/2019 22:04:26 Job5 12/...
1
vote
1answer
26 views

collect logs from bash each 24 hours [closed]

my idea is to collect logs each 24 hours ,mail it and flush them after that i wrote some scatch for example 1.var/log/auth {some info} 2.var/log/something.log {some info} list="$(find /var/log -...
2
votes
2answers
177 views

date command in busybox not accepting formatted input date

I want to set the date using busybox's date command (BusyBox v1.21.0). My custom date to which I want to set the computer is of this form: Tue, 15 Jan 2019 10:46:13 GMT What my date command is ...
0
votes
1answer
76 views

Set date on embedded linux with limited busybox (no ntp)

I am trying to automatically set a date after boot on an embeddd linux with busybox ( I dont have a RTC). I also dont have ntp command in busybox, nor curl. My wget is very limited too, and I cant ...
0
votes
1answer
262 views

date: invalid date trying to set linux date in specific format

i try to set linux date & time in specific format but it keep giving me error Example : date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01" or date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:...
2
votes
1answer
38 views

Improving performance of Script Using find and exec [closed]

I have a script that iterates through a given directory and automatically compresses those that do not contain at least one file used in less than 30 days. Now, I am wondering if I could improve ...
6
votes
5answers
698 views

How to delete all directories in a directory older than 2 weeks except the latest one that match a file pattern?

I have the following path: /dir1/dir2/ In this path I have the following directories containing various (not relevant) application detrius: follower1234 1-Dec-2018 follower3456 2-Dec-2018 ...
9
votes
1answer
513 views

get three-letter day name from date command

date +%b gives me the three-letter abbreviation of the current month name (I found that out online, it's not in my man date nor can I find the answer to this question in my man date). How do I get ...
2
votes
2answers
105 views

Convert docker container dates to milliseconds since epoch

I'm trying to find long-running docker containers. First running docker ps --format '{{.RunningFor}}' returns something like About a minute ago 11 minutes ago which is completely useless for ...
5
votes
2answers
768 views

Subtract time using bash?

Is it possible to use bash to subtract variables containing 24-hour time? #!/bin/bash var1="23:30" # 11:30pm var2="20:00" # 08:00pm echo "$(expr $var1 - $var2)" Running it produces the following ...
0
votes
0answers
26 views

grep text with dates 30 days older within a file and move to another file

unix script to grep text with dates 30 days older than current date within a file and move to another file without having to manually input the current date should be the system date automatically in ...
0
votes
1answer
31 views

Unix/Linux command to get the future time for the any given time value

I have used the below commands to find the 30 mins older time but not able to frame commands to add 30 mins. Sample structure of input. dateinput=20181214202959 inputTime=$(echo $dateinput | sed 's,\...
0
votes
3answers
54 views

Using find to list directories that haven't been accessed since a certain date?

Using the stat command one can see and format the last date a directory was accessed. The adate Is it possible to use find to find the directories that were changed before a certain date using a ...
-2
votes
1answer
162 views

grep dates in a text file to less than 30 days old and move to a new file [duplicate]

A script that should look out for texts with a date inside the file thats 30 days older than the current date then move to another file like the $ awk '$NF <= "2018-05-01"' ip.txt but need a ...
2
votes
2answers
263 views

Sort lines according to date and time

I have this file which represents a calender. Each file has the exact date and time, then the name event and a note. 06-12-2016,12:00,gym,leg day 05-04-2018,12:09,gym,hands 09-08-2019,13:08,movies,...
0
votes
2answers
33 views

Bash: compare target date to series of dates

Given a target date and a set of two columns (the first being a random number and the second a date in order from most recent to oldest), I want to find the number for the row with the date closest to ...
0
votes
2answers
62 views

Pick off 'first' dates using cal function in bash

I'm trying to pick off the first Monday, second Tuesday, second Saturday, etc. out of the cal function and piping awk commands. For this month, I can get the first Tuesday correctly with the command ...
7
votes
1answer
429 views

Which service provides time-sync.target in systemd?

How can I recognize which service provides time-sync.target in systemd? Is it configurable or is it hardcoded in systemd? How can I configure my custom time-sync daemon/service to provide this target?
0
votes
1answer
262 views

how to sort file by DD-MM-YYYY dates

in a file containing : ... 18-11-2018:othercharacters 10-11-2018:othercharacters 03-10-2018:othercharacters 30-10-2018:othercharacters 27-09-2018:othercharacters 03-12-2018:othercharacters ... the ...
1
vote
1answer
190 views

How to Convert Vector number 5-digit number into date format

I am trying to convert the date format something like 10/03/2018 to 43376 in shell scripting, this can be done by using format cell option as the number in excel. How can do it in shell scripting?