Create file base on server time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create file base on server time
# 1  
Old 11-14-2012
Create file base on server time

Hi Guys,

Server time:-

Code:
>date
>Wed Nov 14 11:56:23 EST 2012

I want to convert in to Below Formet :-

Code:
20121114.1100

And cretae file base on above data : last 48 Hour

Code:
20121114.1000 20121114.1100
20121114.0900 20121114.1000
20121114.0800 20121114.0900   
20121114.0700 20121114.0800  
20121114.0600 20121114.0700  
20121114.0500 20121114.0600  
20121114.0400 20121114.0500  
20121114.0300 20121114.0400 
20121114.0200 20121114.0300 
20121114.0100 20121114.0200 
20121114.0000 20121114.0100 
20121113.2300 20121114.0000 
...
...

20121113.0800 20121113.0900

Thanks
# 2  
Old 11-14-2012
Code:
date '+%Y%m%d.%k00'

20121114.1200

This User Gave Thanks to in2nix4life For This Post:
# 3  
Old 11-14-2012
Code:
COUNTER=1

while [ $COUNTER -lt 48 ]
do
        file_name=$( date --date='-'"$COUNTER"' hour' +"%Y%m%d.%H00" ); COUNTER=`expr $COUNTER + 1`
        touch $file_name
done

This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Create new folder and text file the same time in one line

Is it possible to create new folder and write a new text file in the folder while the current position is outside the new folder? in one line mkdir folder | echo "hello test"> folder/test.txt not work. (1 Reply)
Discussion started by: cmdcmd
1 Replies

2. Shell Programming and Scripting

How to create a file in remote server from local server?

hi, can anyone tell me how can i store the names of a file that are in remote server to a file and then get the file that contains the name in local server? there is a remote server where 5 files are present , say a.txt b.txt c.txt d.txt e.txt i want to write a script in my local... (4 Replies)
Discussion started by: Little
4 Replies

3. Shell Programming and Scripting

Create new file when time change

Hi, I have one script, which is tailing from a log file. And I want to separate the output in different files based on the timestamp. Something like that: ./script.sh >> log_`date '+%Y%m%d%H'`.log When I start the script it creates file, e.g. log_2013042314.log, and it is appending the... (6 Replies)
Discussion started by: apenkov
6 Replies

4. Shell Programming and Scripting

How to create tgz file for all the directories in one time?

Hi, On server there is an one folder . which contains sub folder Eg - TEST folder contains test1, test2, execr ,tt (folder). also includes some text file like abc.txt psp.txt gg.log. here iwant to create tgz file for all the folders and file in one time. I know the command... (1 Reply)
Discussion started by: aish11
1 Replies

5. HP-UX

How to rename file in FP server with server time stamp?

Hello All, I am new user in this forum. Facing problem when trying to download file using Perl ::NET:FTP module. I need to rename the remote server file with latest timestamp of that ftp server. Can somebody help me if this is possible? Many thanks, (5 Replies)
Discussion started by: krsnadasa
5 Replies

6. Shell Programming and Scripting

Doing math on 24 hour time base

I'm trying to do some simple math on a 24 hour time base. The time is in the format of HM (HoursMinutes) For example: 2330 #23:30 1800 #18:00 730 #07:30 my problem is with the single-digit hours. If the time is 2200, I use this code: baseTime=2200 minutes=${baseTime:2:3}... (3 Replies)
Discussion started by: jondecker76
3 Replies

7. Shell Programming and Scripting

How to find the create time of a file if current date is in next month

Hi All, I want to find the time diffrence between currnt time and "abc.txt" file create time. I have solve that but if the abc.txt file created last month then is there any process to find the difftent? Exp: Create time of abc.txt is "Apr 14 06:48" and currect date is "May 17 23:47".... (1 Reply)
Discussion started by: priyankak
1 Replies

8. Ubuntu

How to build as web base File Server

Hi folks, Ubuntu 7.04 server amd64 apache2-2.2.3 postfix-2.3.8 mysql Ver 14.12 SquirrelMail version 1.4.11 I have a running Mail Server. I need to make it as a file server, in addition, allowing users who have accounts (Linux/shell) on the Mail Server to upload/download their files... (1 Reply)
Discussion started by: satimis
1 Replies

9. Shell Programming and Scripting

How can I create a file with current time - 60 minutes

I'm using k-shell in unix and I want to create a file with the current system time - 60 minutes. I know I can use touch to create the file, but I'm having trouble specifying how tell it to use the current time less 60 minutes. Any ideas??? (4 Replies)
Discussion started by: DaveyTN
4 Replies

10. UNIX for Dummies Questions & Answers

time stamp of file create

Hi, Sounds a simple request but I also need (would like) to gather the seconds too. I'm not even sure if this is held. I would think it is, somewhere??!!?! I belive that stat would/could work but I don't do C (we'll not yet). Is there any comamnd line util I can use? SunOS. Cheers... (7 Replies)
Discussion started by: nhatch
7 Replies
Login or Register to Ask a Question