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

learn more… | top users | synonyms

0
votes
1answer
33 views

add 10 days for UNIX timestamps output

I've file contain many of epoch / UNIX timestamps need to add for example +10 days for output date so then I will get new date and I've create bash script with date command but seems doesn't work ...
3
votes
3answers
315 views

How to sleep until a given date & time?

I want to write a shell where given a date (day-hour-min) e.g. 10:00 AM Sun 2:30 PM Mon ... It sleeps until that exact date & time. I thought one way of doing it is, I could get the current ...
1
vote
2answers
36 views

Renaming a file the moment it appears in a folder

Here's the context : on a samba server, I have some folders (that we'll call A,B,C,D ) which are supposed to receive files from a network scanner. The scanner renders a PDF file named like this : ...
3
votes
1answer
72 views

How can I output month name in a given timezone

I would like to have the output of date +"%B, %d %Y" in my local timezone but considering another timezone for the names (month name in this case). In my system the date +"%B" outputs (please note ...
0
votes
1answer
26 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) ...
0
votes
2answers
25 views

search the most latest's file name

I am writing a bash script to look for a file which's file name is most recently and file name like: ... Wed_Dec_30_16:47:41_PHT_2015.zip Wed_Dec_30_16:00:41_PHT_2015.zip ...
1
vote
2answers
25 views

Output both ps and Date on one line, to a file?

I am building a rudimentary logging script, and want to capture the output of ps up 12345 So far I have: DATE2=`date +%Y-%m-%d:%H:%M:%S` echo ${DATE2} >> $filename ps up 12345 --no-headers ...
3
votes
1answer
38 views

how to remove 0 (zero) from the day and month but not from the year (01/09/2012) using in Linux (Redhat)

Using Linux (Redhat) I need some help regarding the a/m request When I use dialog: --calendar to output the date. The format will be dd/mm/yyyy but I need the format to be d/m/yyyy for day and month ...
0
votes
1answer
13 views

Count the number of files with yesterday's date in ls's output

I would like to count the number of files with yesterday's date in ls's output. I tried: yday=$(date --date="yesterday" +"%b%Oe") ls . -ltr | grep $yday | wc -l The problem is that files have dates ...
0
votes
1answer
14 views

How to set date with Epoch format

I want to set date from a seconds since epoch value, for instance I want to set date with input value 1452053571. I read through date -help but not found anything. Is there any parameters to do it?
3
votes
2answers
97 views

Find all files modified around a known one

An installer which isn't really clean (Adobe Acrobat Reader DC) installed on my Unix (Mac OS X) a lot of files in different places. I have a reference file Application which I am pretty sure was ...
0
votes
1answer
41 views

Setting time and date without using NTP

I have a "windriver" linux based Wimax ASN, and when ever I login, I find the date and time is wrong (example: "15 jul 2010"). Whenever I set both the date and time with the date command, or the ...
3
votes
3answers
19 views

jump to current day's directory in a date based directory hierachy?

I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/ By itself this wouldn't be bad, but since I ...
3
votes
1answer
32 views

How to I convert month name to number in BSD date?

I have found solutions for GNU date, but not for BSD date. I would rather not make an if, etc. before I know if there's a built in way.
1
vote
1answer
73 views

How to extract date and calculate if it is within “x” days from today?

Currently I have file with structure as Foo Sign: blah SubFoo Sign: blah BarDate: 2017-11-31 Foo Sign: blah BarDate: Never Foo Sign: blah BarDate: 2016-12-20 Foo Sign: blah ...
3
votes
2answers
30 views

Date change format in unix

I am passing date as variable in function. I want to convert that date in different format. Example DT=2015-12-08 Want to convert DT to 08-dec-2015 in Unix.
1
vote
1answer
23 views

How to see the lines whose date column is less than x day from today

My file ID=29524 02/12/2015,23:59:34,'PAt, 0, ID=29628 02/12/2015,23:59:37,'PAb, 1.9, ID=30816 03/12/2015,00:00:20,'PAc, 4.15, I would like to print files with X days less than from today. My try ...
1
vote
2answers
77 views

How to get yesterday date and stored into one variable

I am having a log file where I need to grep based on yesterday date. How to get the yesterday date. The time stamp in the log file is formatted as: Wed Sep 23 for two digit Wed Dec 1 for one digit ...
0
votes
1answer
128 views

Can I see always time in console?

I would like to set the Linux console such that it shows the current time always in console's upper right corner. Is that possible to do? Or is it wise to do if one can never be sure if the cursor is ...
1
vote
1answer
27 views

date: Getting next certain hour

I want to get a date-time string in the future, for example I always want to get the next time of 9:00 am. I know the string formats like "tomorrow" or "next day" to get a certain date-time string. ...
0
votes
5answers
75 views

Bash:decrementing american date by 1 day mmddyyyy

To simplify the problem, lets say I have variable: dat="10152015" (representing 15th October 2015) the result for dat should be 10142015 Note that I am not using today's date. What I have problem ...
0
votes
1answer
56 views

Convert date strings like 20 July 2017 to epoch and compare in Linux

I am using ksh, and have a text file with several lines of following content. I am trying to compare the date part to current date and find the difference in days and then output the "Server" and ...
0
votes
1answer
57 views

How to find files that were most recently created on file system?

I am trying to track the completion of a silent installer by detecting the presence of the last file created by it, but in order to do that I need to find out which file that is. Is there any way to ...
0
votes
2answers
38 views

Set yesterday Date in script special for Monday

I am writing a script a check whether exist a backup file every morning Monday to Friday. These backup file is saved in the end of everyday from Monday to Friday only named as 02_10_15 There is ...
1
vote
1answer
30 views

Extract entries from a file ranging from one date to another

There is a file which has entries with the first and second field as date and time in the following manner : 2015/10/14 00:33:37. The file has 100,000+ lines and is constantly updated. Entries in the ...
1
vote
4answers
114 views

How to get the last five business days in a Unix shell script using a `for` loop?

The following script: BUSSINESS_DATE=`date -d "-2 day" +"%Y%m%d"` for (( c=0; c<5 ; c++ )) do WEEKDAY=`date --date="$BUSINESS_DATE -$c day" +%w` if [ $WEEKDAY == "0" ] then ...
0
votes
2answers
47 views

Date format for variable

I need to write a variable with "date" function and I need that the format is yyyymmdd (i.e. 20151031). Also I would remove a day (i.e. 20151031 becomes 20151030) I would use bash. Thanks!
0
votes
1answer
99 views

Execute a command every minute forever using 'date'

I'm looking for a way (bash script or other) to make a command run every minute using date - I've been looking around for similar solutions but they all suggest either cron or watch but what I want to ...
0
votes
2answers
35 views

Get the first column of date linux

When I run date on my linux I get Sat Oct 31 11:53:22 BRST 2015. I want to get only Sat. How do I do that? So far I think I should use the code below but it does not work: date | printf $1
3
votes
1answer
110 views

Why does “date” show different times in root and user?

Using dpkg-reconfigure tzdata I have set my timezone to CST, but for non root users the system persists in using UTC time. pi@raspberry ~ $ date Wed Oct 28 18:14:08 UTC 2015 ...
0
votes
1answer
148 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 ...
0
votes
0answers
35 views

Reset time / date to current time-zone using timedatectl preferably, or date

As the title says, I'm looking to reset the current system time to the selected time-zone using the timedatectl preferably, or date command. This is on the CentOS 7 OS, hence the timedatectl ...
0
votes
1answer
49 views

Error in 'date -d' command

Hmmm... Right now (Sat Oct 24 00:36:56 CDT 2015) on my Arch Linux system there appears to be a problem with the date command: $ date -d "+8 days" "+%A %d %B %Y" Sunday 01 November 2015 $ date -d "+9 ...
5
votes
3answers
322 views

Unix epoch in milliseconds

I'm prepending the Unix epoch with "nanosecond" precision into output of my command as below: $ command | while read line; do d=`date +%s%N`; echo $d $line; done > file I looked around to find ...
5
votes
2answers
270 views

Datecalc equivalent for Linux

Am using a script in ksh to get a date 91 days prior to today using datecalc on a Solaris 10 server. What would be the equivalent to this in Linux ? month=`datecalc -a $(date +"%Y %m %d") - 1 |awk ...
3
votes
2answers
115 views

How can I check whether $date1 is before $date2 in shell?

date1=$1 date2=$2 How can I check whether $date1 is before $date2? Both dates are in DD/MM/YY format i.e. 01/01/15.
1
vote
2answers
137 views

Compare two times in HH:MM:SS format - ksh

Is it possible to compate two time (24-hour format)? What I need is to just check if the first time is earlier than the second time. Example: $ ./script.ksh 09:30:15 13:00:34 okay $ ./script.ksh ...
1
vote
1answer
245 views

invalid date error for %m%d%Y format

I want to convert a String in %m%d%Y format to date. But, getting invalid date error as shown below: bash-4.1$ date -d '10042015' +"%m%d%Y" date: invalid date `10042015' How to fix it?
0
votes
4answers
889 views

check if date argument is in yyyy-mm-dd format [closed]

Is there a way to check if a date argument is in the correct format (YYYY-MM-DD)? I got this from the web but it doesn't work for me: date "+%Y-%m-%d" -d "2015-10-11" > /dev/null 2>&1 ...
1
vote
3answers
142 views

Excluding specific date and time in cronjob

I am trying to schedule a cron job where the requirement is the job has to run every day, every month and every min and every hour EXCEPT 2nd and 4th sunday of every month from 1 to 3 AM. Is there a ...
1
vote
1answer
110 views

BASH AWK Script add days to fixed date

My task is to export data from a database with the UNLOAD TO statement in dbaccess and convert it into a file, that can be inserted into a similar database. Now the problem: The old database (let's ...
0
votes
2answers
79 views

Subtract two dates using Shell Scripting [duplicate]

How can I subtract two dates in epoch format using Shell Scripting. I want the output in Months, Days, Hours format. Also It should work even for more than 12 months ( as I came across few which were ...
2
votes
4answers
48 views

how to get a different time-clock on CLI apart from your time-zone?

Is there a way to invoke or know a different clock or time on the CLI. The thing is I'm on UTC+5:30 time but at times need to know time in different time-zones. If there is a CLI way in which this can ...
3
votes
2answers
68 views

Script to compare job date to today's date and only output today's failures

Full disclosure: We do not have full access to the autosys database, so our only option for keeping history is to create an Oracle and use the autorep command to output data. We have Linux servers ...
-2
votes
1answer
41 views

How can I write a bash script that tells me how many hours there are from 23:43 to 02:10?

How can I calculate with hours and minutes in bash? For example say I want to write a script that takes two timestamps and tells me how many hours there are in between them, how can I do that? $ ...
3
votes
2answers
311 views

How to convert date from “Oct 01 20:00” to “Oct 1 20:00” format (space padded)?

Here Oct 01 has to be printed as Oct 1 i.e without 0. I need two spaces between Oct and 1 i.e like Oct 1.
5
votes
1answer
71 views

When is next Monday?

On my home computer (Xubuntu 14.04), I have zev@home:~$ date +%F 2015-10-05 zev@home:~$ date +%F -d "next Monday" 2015-10-12 whereas at work (Red Hat 5.11), I have zev@work:~$ date +%F ...
2
votes
1answer
144 views

Why does `date` show UTC time, even with a different timezone set?

I'm running Raspbian on a Pi 2, and I've run into a bit of a pickle. While I'm not sure this behavior was different previously, running date outputs the same time as date -u, despite my timezone being ...
1
vote
2answers
74 views

Compare two dates with different format [closed]

I have two files, each file contain a different date's format as below: File1: 2014-NOV-0620:59:59 File2: 2014-12-31 How can I compare those two dates in awk?
3
votes
1answer
87 views

Automatically synchronization between system time and hardware clock time

I'm working with a Linux embedded board. It uses Linux kernel v2.6.37 with an external I2C RTC cbc34803. I've successfully intergrated the RTC hardware. It works correctly except the problem ...