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
3
votes
2answers
2k 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. ...
2
votes
0answers
427 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 ...
1
vote
1answer
962 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 ...
4
votes
2answers
1k 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
70 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 ...
1
vote
1answer
1k 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
114 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
401 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
392 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
129 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
189 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 ...
-5
votes
2answers
68 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
228 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
540 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
80 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
63 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
1k 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
60 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. ...
0
votes
1answer
6k 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
107 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
1k 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
142 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 ...
4
votes
2answers
2k 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 ...
3
votes
1answer
3k 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
409 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
17
votes
7answers
6k 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
79 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
69 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 ...
14
votes
5answers
3k 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
501 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 ...
1
vote
1answer
1k 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
33 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 ...
2
votes
2answers
888 views

grep date and time from txt file for new variables

I need to extract dates (year,month,day) and times (hour,minutes) from a text file and use them later as variables. Not a homework, just trying to do something useful for my work. I am new to Linux. ...
0
votes
1answer
49 views

Is there a cross-platform "time units separation" standard?

When I create backups with date I usually put the current date as part of a backup file in the format of: year-month-day-hour:minute:second so I get a file like: database-username_database-name---...
1
vote
1answer
100 views

Bash condition that won't run on first Thursday of the month

I have a cron that runs a script twice a week (Monday/Thursday) - this runs fine, but I need to stop it processing on the first Thursday of the month. I'd like to adapt this code: we=$(LC_TIME=C ...
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
98 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
281 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
800 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
5k 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
859 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
237 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
212 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
510 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
47 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
59 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
829 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 ...

1 2 3
4
5
22