Date is a command line utility for printing or setting the date and time.

learn more… | top users | synonyms

3
votes
1answer
306 views

Add 30 days in date

Using bash or mysql , how can I add 30 days in user expiry table? Example I have DB name USERS and table expiry like this: USERNAME EXPIRATION JOHN 2015-09-26 I want the command to take ...
2
votes
1answer
30 views

The arithmetic operations in bash date… ¿are reversed?

Edit: using Amazon Linux: Linux ip-xx-xx-xx-xxx 3.14.44-32.39.amzn1.x86_64 #1 SMP Thu Jun 11 20:33:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Output of this command: date +"%Y-%m-%d %H:%M:%S" ...
1
vote
0answers
13 views

date/time setting does not work after unplugging power adapter or sudden power cut

For some reason, I want to configure the date/time in my Linux (CentOS 6.5) to be different from the REAL date/time, but the setting won't work if I turn my computer(desktop not laptop if this ...
10
votes
3answers
742 views

What's a smart way to count the number of days since X?

I started working at my current position since November 17th 2014. I would like to know how many days have run up to now. Any ideas on how to use Linux to come up with a simple and nice solution ?
11
votes
3answers
420 views

Date validation in shell

I want to validate the below date format in shell script 2015-Jul-13 I'm using date -d "2015-Jul-13" +"%Y-%b-%d" but its giving error as date: invalid date '2015-Jul-13'
1
vote
1answer
33 views

Why is the localtime reset to the default timezone?

I use the following commands to set the timezone on our Amazon Linux (Centos) server: ls -al /etc/localtime -rw-r--r-- 1 root root 118 25 dec 2012 /etc/localtime sudo mv /etc/localtime ...
1
vote
3answers
57 views

epoch time for GMT

On AIX date -u gives date and time in GMT format date gives date and time in local timezone date +%s gives local time in epoch time Is there a way to get GMT time in epoch format? In the AIX I'm ...
3
votes
4answers
144 views

How to compare two dates without using Stat?

I'm trying to compare the last date modified of a file to today's date. If the modification date is before today's date then my script will do one thing, if the date matches todays date i need it to ...
4
votes
2answers
58 views

date processes first parameter incorrectly if it is not 1

I am using date (GNU coreutils) 8.22 and having some trouble to calculate a date after a given one. Say I want to use 1st of February, for example: $ date -d'1 February' Sun Feb 1 00:00:00 CET 2015 ...
0
votes
3answers
72 views

In bash, how to call a variable and wrap quotes around its value as part of a command without causing the variable name to become a string literal?

So I want to add 10 seconds to a time. The command to do that came from here. To illustrate: STARTIME="$(date +"%T")" ENDTIME="$STARTIME today + 10 seconds" CALL="$(echo date -d $ENDTIME ...
0
votes
1answer
88 views

Unix date format validation script

I wrote this small unix shell script to validate the date format. My script should check whether the string is in YYYYMMDDHHMISS format . If it is not in this format , it should send an error message ...
0
votes
1answer
40 views

Print a date with leading zeros

My requirement is to print date like this, 04.10.2015 I have tried, d=`date '+%d%m%y'` But the problem what was happening, it was printing those dates which are two digits (10 to 31). But 1 to 9 ...
10
votes
3answers
553 views

How do I get the current time in a different time zone without changing system time? [duplicate]

I am trying to use 'date' to get the time in a different time zone, and failing. All the methods I've found on google involve changing the time zone on the system, but that is not what I want. Is ...
1
vote
1answer
29 views

install date time picker on ubuntu server [closed]

I've recently created a kiosk which uses openbox and xorg in order to be able to show the browser. Is there also a way that I can run some command in the server and it will open a graphical date and ...
2
votes
3answers
37 views

Truncating the precision of a date

I'm working with a bash script which polls build progress from several different systems. If a build is complete, it stats a log file to find out the last time it was edited, then feeds that time into ...
6
votes
1answer
144 views

How does the “1 month ago” option in date command work?

I'm not sure if this gets the past date within the current day or if it only takes 30 or 31 days to it. e.g. If the current date is March 28th, 1 month ago must be February 28th, but what happen ...
0
votes
1answer
53 views

set my system date & time via terminal

I don't why a + sign appears in the my program: <ns1:ST>2015-05-23T18:00:00+04:00</ns1:ST> <ns1:ET>2015-05-23T18:15:00+04:00</ns1:ET> this is when I run the program in my ...
6
votes
1answer
94 views

Change a locale definition (as opposed to a locale setting)

Preliminary remark: This question is not about setting a locale by changing LC_ALL, LC_TIME, LANG, etc., it's rather about changing a locale definition, e.g. in /usr/share/i18n/locales/de_DE, or ...
3
votes
0answers
67 views

Best practice to customize date/time format system-wide?

I'd like to customize exclusively the date and time format for my system, while sticking to the rest of the locale as is. I know that environment variable LC_TIME will make it possible to customize ...
3
votes
1answer
210 views

Copy a file and append a timestamp

I've got two issues with my script that copies files and adds a timestamp to the name. cp -ra /home/bpacheco/Test1 /home/bpacheco/Test2-$(date +"%m-%d-%y-%T") The above adds Test2 as the filename, ...
2
votes
3answers
72 views

Reformat date string

I am trying to figure out how to reformat a file full of wrongly formatted dates. The source looks like this: {"_id":"","timestamp":"Mon Apr 20 08:30:55 +0000 2015"} {"_id":"","timestamp":"Mon Apr 20 ...
1
vote
1answer
37 views

Using date -1day with wget

I want to use wget with a cron to pull a file everyday however I want it to pull the previous days file from the remote server and the file is controlled by date variables in the URL as such: ...
0
votes
1answer
62 views

Usage of '%' in the crontab [duplicate]

I am trying to add a cron job to perform an rsync from a remote server to a (Ubuntu12) local machine & create a log file. Below is the crontab-l 00 18 * * * rsync -a -v --delete -e ssh ...
4
votes
2answers
68 views

Force time to stay put

The time on my Linux machine will not stay put. I need to test an issue with our server that only occurs on Saturdays. CentOS 6.5 64-bit I have NTPD off. (service ntpd stop and chkconfig ntpd off) ...
2
votes
2answers
118 views

date: bad conversion error on HP-UX but not on Linux

On Linux: $ touch 1 12 No problem,create 1 and 12. On SysV or HP-UX 11.31: $ touch 1 12 date: bad conversion I have tried with LANG=C, same error. Why?
1
vote
1answer
34 views

How to print a concatenated date and time in seconds

How can I print the following date 20150405 12:35:12 in seconds cur_date=20150405 cur_time=12:35:12 cur_datetime=20150405 12:35:12 this is what I am doing: cur_datetime=$cur_date' ...
4
votes
2answers
144 views

how to sort by the day of the week?

I have two files. file1: Dave 734.838.9800 Bob 313.123.4567 Carol 248.344.5576 Mary 313.449.1390 Ted 248.496.2204 Alice 616.556.4458 file2: Bob Tuesday Carol Monday Ted Sunday ...
0
votes
2answers
57 views

Change only the year on the output of the “date”-command

date for example displays Fri Apr 17 20:16:01 IST 2015 Now I want to change only the year so date should display Fri Apr 17 20:16:01 IST 2016 in this example. How to add 1 year to the output of date ...
1
vote
1answer
85 views

shell script for date checking between two days

There is date in my file, like 30-apr-2015. How can I compare this with the current date and get notified if they are equal?
0
votes
0answers
27 views

date advancing quickly ubuntu 14

after an upgrade of my server from ubuntu 12.04 LTS to ubuntu 14.04 LTS my system date is advancing quickly (taking 1h every 10 minutes). I tryied to install an ntp server to correct date but no way ...
1
vote
1answer
50 views

Figuring out the dates for a given week

With date -d @[some_timestamp] +"%U" the end result is a number between 0-53, which represents the week in which the [some_timestamp] is located. So if I have an arbitrary timestamp ie 1426815663, the ...
0
votes
1answer
64 views

How to accumulate data for the previous x number of days

Q: For the argument of the question, say today is 26/03/15. How can I 'accumulate' data for the last 5 days. But these dates are just an example. Ideally I would like to be able to accumulate data ...
0
votes
0answers
53 views

reading dates from process substitution using awk. Issue with field separator, splitting tokens incorrectly

I have the following code, thanks to @Janis for the help with the process substitution. Also, apologies for creating a new question, I haven't received any recent replies on the thread of my previous ...
2
votes
2answers
65 views

Porting Linux date parsing to FreeBSD

I have date in this format: date -d $datum +"%Y-%m-%d" and on Linux it worked OK but in FreeBSD says this: ERROR wrong format usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
3
votes
4answers
233 views

What else apart from /etc/localtime and $TZ affects `date`?

I have a fedora 20 installation with the clock set to UTC, and no TZ environment variable. Why the date command is outputting the date in the CET timezone (which by the way is my local timezone)? ...
3
votes
0answers
206 views

Why does the syslog timestamp not include a year?

I am planning to store some of my log messages for more than a year, but the syslog timestamp description from RFC3164 does not include a year in the timestamp portion of a log entry. An example ...
2
votes
2answers
192 views

How does one append a unix timestamp on a filename which is inside an argument?

To be more specific, I want the Unix timestamp to be appended to my file name: db:backup --database=mysql --destination=s3 --destinationPath=date+random.sql --compression=gzip However, this gives ...
0
votes
1answer
110 views

Modify date in email header using script with mailx

I am trying to modify a script which grabs data from a database and puts it into the message of an email which is then sent out using mailx. What I need to do is grab the date which is in the first ...
0
votes
2answers
28 views

Can setting random date cause problems under a UNIX desktop? [closed]

If we write a script that sets the date on a UNIX Desktop (so Linux, BSD) to a random one, example: in every minute, a new date is set: 1983.03.12 15h:17; 2039.04.01. 03:17, etc. Q: What problem ...
0
votes
3answers
64 views

Simple method to find the number of seconds between two (non-standard) date formats?

I have a program which outputs dates in the following form: Thu Mar 5 09:15:27 2015 This is very close to the output of date in Linux, but this format does not include time zone. Assuming I can ...
0
votes
0answers
46 views

Get first day of the month

I need to get the first day of the month in this format "%y%m%d" or 150301 I can get the current day in this format: date +"%y%m%d" But the first day of the month is a lot trickier. Any thoughts? ...
3
votes
3answers
199 views

Calculate date difference between Last modified date of a file and NOW using shell script

I am trying to calculate the time elapsed since the log file was last updated. I guess following commands will be used lastUpdate=$(date -r myLogFile.log) now=$(date) How can I subtract them and ...
1
vote
1answer
586 views

shell command to know computer manufacturing date [closed]

as object, I would like to know when a computer was built and also last OS installation date
0
votes
1answer
53 views

tail-ing a filename that is a date [duplicate]

I am creating a logfile from kermit named the current date (which is in the format of DD MMM YYYY - which can not be changed AFAIK), and using the file name as today's date. I then have a Bash script ...
0
votes
0answers
61 views

timedatectl not persisting time when set manually

Configuration before any attempts to modify it as per timedatectl: Then, I set the time manually timedatectl --adjust-system-clock set-time "2010-04-20 04:30:50": Nice, works! Now, I rerun ...
1
vote
3answers
152 views

Replace date with current date

I have a file abc.fil whose content is in the format yyyymmdd.xyz.doc. I want to cat that file abc.fil such that I get the output as 20150127.xyz.doc. Can any one please help me to resolve this ...
0
votes
2answers
82 views

Get all the records from a file with Date collumn less than a month

Input file ID,Name,join_date 21433432,rds,2014_02_01 2131321,ABCDS,2014-10-20 2432745314,ASRER, 2015-01-20 2132432423,safdsad, 2015-12-30 Need two files created one for records with the date column ...
3
votes
3answers
138 views

Get modification date that can be used with touch -m

I need to get the modification date of a file so that I can set it on other files using touch -m. stat or perl -le 'print((stat shift)[9])' Didn't return what I wanted. I think that you are supposed ...
0
votes
1answer
503 views

Bash script, ask for user input, to change a directory, sub directorys, and file's mtime atime linux recursively

Using GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) I am a bash scripting novice, not sure where to begin except at shebang #!. The following command. touch -a -m -t 201501010000.00 ...
4
votes
3answers
1k views

How to represent date format in '2015120' in Linux shell?

My colleague is generating log files with a preceding date format like 2015120, which represent January as 1 instead of 01. The usual way I'm using to deal with this kind of issue is using date ...