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

learn more… | top users | synonyms

0
votes
2answers
29 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
41 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
18 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
38 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
46 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
34 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
39 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
93 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
87 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
162 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
29 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
25 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
37 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
38 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? ...
2
votes
3answers
78 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
364 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
32 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
31 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
85 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
44 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
109 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
200 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
932 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 ...
-1
votes
2answers
119 views

How to convert date format in file

Input file: Contains 3 columns with the 3rd column is date in DD-MMM-YYYY format sample data: 1232,abdc, 02-Jan-2014 4534,kdafh, 20-Feb-2014 364,asjhdk, 11-Jul-2012 required output: 1232,abdc, ...
1
vote
2answers
37 views

change non-zero padded hour and minute into 24hr time

I have data that I need to change before running it through the pandas library in python. It is currently in a format that stores midnight values as 2400 and that should be changed to 0000. The ...
2
votes
1answer
46 views

calendar to check the date and then search 3 months back and add up the days of those months?

I want to use the cal comand or the date comand to displace the current day then I want it to displace 3 months before the current date then add up all the days in those 3 months up to the current ...
0
votes
2answers
55 views

append time to log filenames

I want to make log_files named as log_Jan_01_hh:mm:ss, so the variable time-stamp is defined as date +"%b_%d_%T". Now if I set the value to a variable: setenv now `date +"%b_%d_%T"` Then $now ...
4
votes
3answers
215 views

How to append a date to all files in a directory without touching sub-directories via bash script

I'm currently taking a class for Operating Systems and we're learning to do bash scripts as part of the curriculum. I need to append the date to all the files in a directory without touching ...
1
vote
1answer
373 views

How do I put a time stamp with: wget --output-file=[FILENAME] [URL]

So I've been trying to put a timestamp on some images I'm downloading from a webcam, but so far it's been saving the images with the names camera3_date' here's my line that I enter: wget ...
2
votes
2answers
103 views

Get time for system default timezone

When logging in to remote machine X, by default, date will give the time in the local timezone: $ date Mon Nov 17 22:45:47 CET 2014 Note that TZ is not set: $ export | grep TZ $ So, I set TZ to ...
0
votes
2answers
86 views

Can't use argument in bash date calculation script

The following bash script won't work. I need to calculate the date depending on the number of days since 14th Oct 1582, where the argument will be the number of days. d="$1" date -d '14 Oct 1582 + ...
1
vote
3answers
362 views

Date in milliseconds on OpenWRT on Arduino YUN

I am using OpenWRT on the Arduino YUN and I am trying to get the exact date in milliseconds (DD/MM/YYYY h:min:sec:ms) by getting the time by an timeserver. Unfortunately date +%N just returns %N, but ...
2
votes
1answer
51 views

Append same timestamp to multiple filenames

I have several files that I ftp each hour. The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename. That ...
1
vote
4answers
83 views

Sort datetime string in 12-hour format

I have a log file with contents like this: 11-12-2014 - 03:03:59AM lat = 41.990516; lon = -93.430704<br> 11-12-2014 - 03:05:15AM lat = 41.001546; lon = -93.443352<br> 11-12-2014 - ...
1
vote
4answers
364 views

How to subtract two times in shell

I nee to subtract two lines which is in the format of time in shell. Th time format is hh:mm:ss I used the code below to get the time. cat /var/log/kern.log |grep usb |tail -2| awk '{print $3}' The ...
0
votes
1answer
81 views

Why can't my `date` deal with timezones? [duplicate]

I'm having some weird issues with GNU coreutils date v8.4 (CentOS) that aren't occurring in v8.21 (Ubuntu/Mint). On v8.4, I get the following output (I'm in PST): $ date --version | head -n 1 date ...
2
votes
1answer
400 views

Leap seconds and date

I've just discovered that Unix time does not include the leap seconds. I think it's quite surprising because doing that, it is slowly diverging from UTC... but that's not the point of my question. ...
0
votes
1answer
111 views

How to run commands on a variable containing a date?

I need to be able to take a date in the format of "MM/DD/YY" and change it back into the default date format (Fri Oct 31 17:23:07 CDT 2014). This is driving me crazy. The code below may look ...
1
vote
2answers
213 views

How to convert time from local timezone into Sydney timezone using korn shell?

I need to convert time from localtimezone (CET/CEST) to Sydney timezone (AEDT/AEST). I tried something like this: export date=$(date "+%Y-%m-%d %H:%M:%S AEDT") date "+%Y-%m-%d %H:%M:%S %Z" -d "$date" ...
1
vote
1answer
72 views

How to enter date as an option in a bash command? [duplicate]

I want to enter the current date (ideally in the form YYYY-MM-DD hh:mm) as an option in a bash script: I tried /usr/local/bin/growlnotify -t "PMK" -m date but then the variable -m inserts the ...
5
votes
1answer
114 views

date command --iso-8601 option

This answer and comments mention --rfc-3339 and a "hidden" --iso-8601 option that I have used for a long time and now seems to be undocumented. When did that option documentation get removed from the ...
3
votes
3answers
256 views

How do I find a file with a name which depends on the current date (and a random component)?

I have to check a particular path every day and find the file with a name of the form: StaticData_Sets_yyyymmdd-232550.txt The date in the name after the string StaticData_Sets_ is updated every ...
1
vote
2answers
118 views

How to get proper format from date for the touch -A argument?

I would like to change all of the attribute times of some files to the immediate date. It appears that I would need to use touch -A * (more or less; realizing that I am going to use a more complex ...
2
votes
1answer
299 views

date command, going back one or two days. Seeing different flags

I'm writing a bash script that should run on OSX and Ubuntu. I'm not sure if this particular problem is due to an OS mismatch; more likely it's a difference in the date command on the two shells, ...
2
votes
1answer
51 views

Where is using @ before a date string for seconds since the epoch documented?

GNU date and touch commands (and presumably others) use @date to define a date string as seconds since the epoch. For example: $ TZ=UTC date -d@10 Thu Jan 1 00:00:10 UTC 1970 I was answering a ...
2
votes
2answers
101 views

Regarding getting Date - n days Date

Suppose I have a particular date stored in a variable (date_m) . I want ((date_m)-25) date. For eg: I have 15/09/2014 stored in my variable , then I want 21/08/2014 returned if I subtact 25 from the ...
3
votes
1answer
76 views

Save lines to different files based on the date

How can I force a re-evaluation of this each time? cat > $(date '+%H-%M-%S').log So that when I first output something it gets written to one file, and after a few seconds I make another ouput ...
3
votes
3answers
28k views

Linux: set date through command line

How to change the system date in Linux ? I want to change: Only Year Only Month Only Date Any combination of above three
0
votes
1answer
121 views

Change the timezone in a terminal

I connect my web server via SSH Terminal on Mac. cat /var/www/vhosts/example.com/statistics/logs/error_log The Date of my server and local computer differs so output of error_logs is not efficient ...
2
votes
3answers
228 views

Convert a number of seconds elapsed to date from arbitrary start date

I want to convert a particular amount of seconds to a date. In my case the it's the number of seconds elapsed since 1st of January 0001. If it were for seconds elapsed from epoch it would be easy: $ ...