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

learn more… | top users | synonyms

5
votes
2answers
3k views

Good method to compare time?

I need to check for the current time and abort the script if it is not proper time of day I am supposed to run it. Also, if anyone else runs it, it should abort. For example: I need my script to only ...
1
vote
1answer
569 views

Outputting last modification date to another file?

I'm trying to read the number of lines in a file, and the last modification date of that file (e.g. if it was last modified Jan 18, 2013, it should output 2013-01-18), then append the data to the ...
2
votes
2answers
212 views

Linux date/time - monthly “mongodump”

For MongoDB backups, I want to backup only the newest changes from the previous month instead of everything from the previous month. As part of the query I need to pass to "mongodump", I have to ...
0
votes
1answer
3k views

Convert any Date format in unix

How can I convert any user inputted date into yyyy/mm/dd? For example user can input date in one of the following formats 20120121 , 2012-01-21, 01/21/2012, 01/21/2012 etc. But I need to convert any ...
3
votes
3answers
2k views

Solaris: find the day of last Monday,Tuesday,…Sunday by means of shell script

I'm trying desperatly to find a bash or ksh routine that allows me to find for example the previous Monday,Tuesday,Wednesday,... preceding today's date. Additonal it has to work on plain vanilla ...
3
votes
2answers
1k views

I messed up my system clock in Arch Linux

I installed Arch a couple of days ago. Just realized the date/time were off by a day and one hour. I changed it using timedatectl set-time. Then used hwclock --systohc to set the hardware clock. ...
3
votes
1answer
205 views

Awesome: Incorrect timezone

Typically, I set the timezone of my computer's clock by changing the .bashrc file, appending, say, TZ='America/Los_Angeles'; export TZ such that whenever date is invoked the right time in the right ...
1
vote
1answer
323 views

Help renaming folder according to date

I have the folder "Backup yzT Jan-01-2013". I've made also a script for do a backup everyday. The problem I'm facing is how to rename the folder day by day according to date? Get the new name is ...
0
votes
2answers
168 views

I want to add the above date to each line on a prstat log file

I have a prstat log, as you all know the date and time is recorded on the top of the log file, I would like to add that date and time to the begging of each line until it gets to a new date, then I ...
1
vote
2answers
1k views

How to change the language for date command?

I'm using vnstat together with conky. To show the monthly traffic I'm mixing vnstat and grep to find the month. The command to collect the data is ${execi 3600 vnstat -m -i wlan0 | grep "$(date ...
1
vote
2answers
4k views

Solaris + display file time stamp [year][month][day]

I have Solaris 10 machine I need to verify time stamp of some file in my Solaris machine And to get the following format [year][month][day] Example of working command on Linux ls -l ...
2
votes
3answers
4k views

Appending current date to filename

I'm trying to append the current date to the end of a file name, like what we see in logfiles: TheFile.log.2012-02-11 I have been following this example and applied this to both a Unix and Linux ...
2
votes
1answer
152 views

Why are the timestamps on files so old on my newly installed system?

I installed the Red Hat Enterprise Linux 5.6 on a client system today. If it is of any concern, it's running on the bare metal. After the installation was completed, I did ls -ltr / and it showed a ...
4
votes
2answers
1k views

How do you specify a format for the input to date?

Given a date and time in a format that is not recognized by date, how can I get date to recognize the date and time? For example: $ date -d "09SEP2012:23:58:46" date: invalid date ...
5
votes
3answers
4k views

Appending timestamp stamp along with log file lines

I have a log file and I need to append timestamps to each line as they get added. So I'm looking for script that appends timestamps to each entry in log lines and which could run as a cron job. Could ...
7
votes
2answers
4k views

How to find difference between two timestamps up to milliseconds?

I am new to shell scripting. The heart of my script is to find the difference between two timestamps up to milliseconds. With me I have a file with content of timestamps only as 2012-09-13 ...
4
votes
1answer
134 views

How to show full day name with command of e.g. Jul 16 1991

I found out that date --date 'Jul 16 1991' has an complete output, but I only want the terminal to show the name of the day e.g. Monday. How do I do that?
4
votes
5answers
2k views

Convert formatted dates to seconds since the epoch

I have a file: pablo tty8 Thu Nov 1 12:51:21 2012 still logged in (unknown tty8 Thu Nov 1 12:50:57 2012 - Thu Nov 1 12:51:21 2012 (00:00) pablo tty2 Thu Nov 1 12:50:39 2012 still logged in pablo ...
6
votes
1answer
147 views

locale definition with French republican calendar

I wonder if it is possible to create a locale definition that would make the C library format the dates according to the French republican calendar. I expect then, for example, run `date' and get ...
6
votes
3answers
811 views

Equivalent of date --reference in Solaris

The GNU implementation of the date command has a nice feature to show the date of the last modification of a reference file, and using the +FORMAT parameter it is easy to get the date in any format, ...
3
votes
1answer
3k views

show the year while listing files in the current directory

I am working on a red hat server I want to list the files in a way where the year when each was file created would appear in the Date how is that possible ?
4
votes
2answers
367 views

List files created on Sundays

How do I list/find all the files created on Sundays or Mondays? How do I use the date parameter to display them? Something like : ls -f date + %a or find -type f | date +%A or find -type f ...
5
votes
3answers
7k views

Find files which are created a certain time after or before a particular file was created

I need a shell script which finds files which are created 1 hour before or 1 hour after a particular file (test.txt) was created. If I go with find -newer, that means I'd have to create a temporary ...
2
votes
2answers
8k views

linux + add X days to date and get new virtual date

I have Linux ( RH 5.3) machine I need to add/calculate 10 days plus date so then I will get new date (expiration date)) for example # date Sun Sep 11 07:59:16 IST 2012 So I need to get ...
1
vote
2answers
428 views

Parsing the output of date with sed

I am trying to replace the whitespaces in the output of date with '_' with no success. $date Fri Sep 14 14:10:04 EDT 2012 $ date | sed 's/ /_/' Fri_Sep 14 14:10:24 EDT 2012 As you can see, the ...
8
votes
3answers
4k views

How can I have `date` output the time from a different timezone?

I have a server running with the timezone set to UTC. It seemed like that was generally a good practice (please correct me if I'm wrong). Anyhow, one of the servers I connect to, in order to scp ...
1
vote
2answers
13k views

How can I set the time in Centos so that resetting the OS doesn't revert to its default value?

I have a VPS running on Cent Os 5.8 (x86). There are situations in which we are forced to reset the entire VPS (it hangs and the only way to get it back on is to reset it). When we do so, the time is ...
4
votes
5answers
11k views

Display time stamp in dd/mm/yyyy_hh:mm:ss:ms in Unix or Linux

I need help to display date and time in desired format in Unix/ Linux. My desired format is: dd/mm/yyyy hh:mm:ss:ms in Unix or Linux. I got close using the following command: echo $(date +%x_%r) ...
1
vote
1answer
619 views

Change server date using PHP

Is this possible to change Linux server date using php code? Is there any way to give necessary permissions to Apache to do this? What is the procedure to give root permissions to Apache?
0
votes
1answer
319 views

Mplayer cronjob doesn't work [duplicate]

Possible Duplicate: How can I execute date inside of a cron tab job? I made a cronjob to record a stream every friday between 23pm and midnight. Only somehow this doesn't seem to work. ...
2
votes
2answers
690 views

converting unix time to string time with date command

I have read the man pages for date command, but there is no option for converting unix time to string time. I found some websites telling this: date -d @1343715322 there is no option like @ in the ...
6
votes
4answers
3k views

Renaming a bunch of files with date modified timestamp at the end of the filename?

So, say, I have a directory with a bunch of files like g.txt, where g.txt was last modified on, say, June 20, 2012. How would I batch-rename all of the files (like g.txt) with the last modified date ...
1
vote
3answers
5k views

First and last day of a month

Given two numbers, month and year, how can I compute the first and the last day of that month ? My goal is to output these three lines: month / year (month in textual form but that is trivial) for ...
6
votes
4answers
590 views

Date computations without GNU tools

I have to perform some date calculations and conversion in a shell script. For example computing the difference in day between a date formatted as Nov 28 20:27:19 2012 GMT and today. There are ...
2
votes
2answers
220 views

CentOS 5.6 live time feature without repeatedly executing date command

I am using CentOS 5.6, is there a way to view a "live" time, without constantly executing the date command? Constantly excuting the date command can be quite frustrating and repetitive when checking ...
2
votes
2answers
122 views

Is the system time correct when no date has been set?

If I was looking through a debian log file and I come across Jan 1st 1970 08:21:34 in a log, did the action happen at 08:21:34, just the correct date had not been set? Or if no date had been set is ...
1
vote
1answer
114 views

What does XST in the date command output mean?

When executing the date command (on CentOS), it gives me something like this: Thu May 10 20:15:07 XST 2012 My local time zone is CEST, which was at that moment 22:15:07, so the printed time ...
5
votes
1answer
894 views

Get “date” to understand a timestamp phrase of a different language

My web-scraping scripts have long enjoyed using date -d to read in human-formatted time and date stamps like "March 11, 1999" and convert to any other format I need via the -s parameter. How might I ...
6
votes
1answer
388 views

In KDE, how can I create a custom keyboard shortcut that prints the current date?

I often need to print the current date in lots of different programs. Right now, I always type it per hand which is error prone. I'm using KDE 4.8, and it has customisable keyboard shortcuts. For ...
1
vote
1answer
6k views

How can I fake sending -time when sending email with Mutt?

Suppose a student is two hours late in returning an assignment. Now the assignment needs to travel a long way in internet so there is a good excuse that it got lost in somewhere or got jammed (well ...
10
votes
2answers
438 views

What is a distro-agnostic way determine the OS install date?

I am on a CrunchBang machine and trying to write a script that needs to have the OS install date as a reference. I searched and found this command: ls -lct /etc | tail -1 | awk '{print $6, $7, $8}' ...
2
votes
2answers
1k views

UNIX move file name with sysdate

I want to make a script in Unix in which I have to move a file daily to a specific path. In order to avoid overlapping of the file, I want the file name along with the date. e.g. mv filename ...
6
votes
3answers
527 views

sort at jobs chronologically

Possibly a simple solution I misplaced. How can I get the output of atq sorted chronologically, so I can easily see who's due to run next? The man page for sort doesn't have anything built-in to ...
2
votes
5answers
309 views

Is it possible to reference the most recently modified file in a command line argument?

I frequently download PDF files with heinous numeric file names from my browser. These automatically go into ~/Downloads. Ideally I would like to just be able to open these files with: evince "the ...
3
votes
2answers
2k views

List of Recently Modified Files

How can I Get a list of all files modified , say 3 months ago. I checked this question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there ...
2
votes
8answers
2k views

How to generate a year-quarter date from the command line?

I'm interested in outputting a representation of the current year-quarter, as well as the year-quarter for the previous month. If today is 2012 January 1st, I'd like to get 2012q1 and 2011q4 as ...
0
votes
1answer
234 views

Setting system/hardware clock under Debian

I have installed a system with a London timezone, instead of using Central European Time. The problem is, that hwclock says the time is 11:00, date says the time is 11:00. I have changed the timezone ...
14
votes
6answers
21k views

Quickly calculate date differences

I often want to make some quick date calculations, such as: What is the difference between these two dates? What is the date n weeks after this other date? I usually open a calendar and count the ...
2
votes
1answer
437 views

How to insert a first column to many files + how to convert unix time to normal time

There are many-many files in a directory that has e.x.: the following content: INPUT: root 1324711901 sshd 1272725792 And I'm searching for a solution how to convert the content of the ...
3
votes
5answers
3k views

Trying to set date on a Linux based machine from another machine

I am running busy box on an embedded platform. I would like to set the date on the box properly each time I reboot the hardware. I have no way to save the time persistently, so am reduced to setting ...